Skip to main content

RenderService

class · Singleton<RenderService> Unity component singleton
public sealed class RenderService : Singleton<RenderService>, IRenderService

Namespace: AR51.Unity.SDK · Implements: IRenderService

Renders a remote CVS camera's JPG feed into a Unity camera positioned by that camera's extrinsics, composites the scene (holograms) on top, and re-encodes the result as a JPG stream. Use it to display a remote camera view with overlaid holograms. Internally it reads the camera's intrinsic/extrinsic matrices and FOV via CvsCameraInfo to place the render camera. Lives in the scene as a singleton — reach it through RenderService.Instance.

note

Units: AR 51 mocap data and all SDK world-space positions are in meters; rotations are Quaternion; angles in degrees. The frame parameters on this class are in pixels (width/height), frames per second (frameRate), and 0–100 (jpgQuality).

Properties​

PropertyTypeDefaultDescription
Configuration
RenderCameraPrefabGameObject—prefab instantiated per rendered camera
RenderCameraCullingMaskLayerMask—layers the render camera draws (which holograms appear)
Diagnostics
LogDroppedFramesboolfalselog when output frames are dropped

Method summary​

Instance

MethodReturns
StartRenderingBlockingCollection<byte[]>Unity component
GetFeedBlockingCollection<byte[]>Unity component
StopRenderingvoidUnity component

→ Full descriptions in Method details below.

Method details​

StartRendering​

methodinstance
public BlockingCollection<byte[]> StartRendering(string cameraId, string address, int port,
int width, int height, int frameRate, int jpgQuality);

Begins compositing the named remote camera feed and returns the output stream. The service instantiates RenderCameraPrefab, places it using the camera's extrinsics/FOV (read via CvsCameraInfo), renders the scene at the requested resolution, and re-encodes each composited frame to JPG. Call once per camera; pull frames off the returned collection.

Parameters
cameraIdstringid of the remote camera to render (see CvsCameraInfo.Id)
addressstringCVS / camera-feed service host (IP or hostname)
portintservice port
widthintoutput width in pixels
heightintoutput height in pixels
frameRateinttarget output rate in frames per second
jpgQualityintJPG encode quality, 0–100
ReturnsBlockingCollection<byte[]>a blocking collection of output JPG frames (each byte[] is one encoded frame). Take from it on a background thread to consume frames as they are produced.

⚠️ The render camera is positioned by the remote camera's extrinsics; the SDK applies a 180° rotation about Z to map the CVS y-up / right-handed convention into Unity (see GetExtrinsic). If your overlay appears flipped or rotated, that handedness conversion is the place to look.

Exampleinferred
using System.Collections.Concurrent;
using AR51.Unity.SDK;

var render = RenderService.Instance;
// 1920x1080 @ 30 fps, quality 90 — exact camera id/host/port come from your CVS deployment
BlockingCollection<byte[]> frames =
render.StartRendering("cam-0", "127.0.0.1", 50051, 1920, 1080, 30, 90);

// Consume on a worker thread; each item is one composited JPG frame.
foreach (byte[] jpg in frames.GetConsumingEnumerable())
{
// e.g. push to a Texture2D.LoadImage(jpg) on the Unity thread, or relay onward
}

GetFeed​

methodinstance
public BlockingCollection<byte[]> GetFeed(string cameraId, string address, int port);

Returns the same output collection for a camera that has already been started with StartRendering. Use it to obtain the JPG stream from another part of your code without re-starting the render.

Parameters
cameraIdstringid of an already-rendering camera
addressstringthe service host passed to StartRendering
portintthe service port passed to StartRendering
ReturnsBlockingCollection<byte[]>the existing output JPG-frame collection for that camera

StopRendering​

methodinstance
public void StopRendering(string cameraId, string address, int port);

Stops compositing the named camera, tears down its render camera, and completes the output collection. Call this when you no longer need the feed (e.g. on disable / scene teardown).

Parameters
cameraIdstringid of the camera to stop
addressstringthe service host passed to StartRendering
portintthe service port passed to StartRendering

See also​

Was this page helpful?