RenderService
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.
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
| Property | Type | Default | Description |
|---|---|---|---|
| Configuration | |||
RenderCameraPrefab | GameObject | — | prefab instantiated per rendered camera |
RenderCameraCullingMask | LayerMask | — | layers the render camera draws (which holograms appear) |
| Diagnostics | |||
LogDroppedFrames | bool | false | log when output frames are dropped |
Method summary
Instance
| Method | Returns | |
|---|---|---|
StartRendering | BlockingCollection<byte[]> | Unity component |
GetFeed | BlockingCollection<byte[]> | Unity component |
StopRendering | void | Unity component |
→ Full descriptions in Method details below.
Method details
StartRendering
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.
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.
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
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.
StartRenderingStartRenderingStopRendering
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).
StartRenderingStartRenderingSee also
CameraService— controls this device's local camera capture/streaming (vs. rendering a remote one)CameraFeedClient— enumerate remote cameras and fetch theirCvsCameraInfoServiceManager— the connection entry point that stands up the service hostCvsCameraInfo— the remote-camera data model whose matrices position the render cameraGetExtrinsic/GetVerticalFOV— theCvsCameraInfoextension helpers used internally- Class index — all Unity SDK types