Skip to main content

CameraFeedClient

class · transport assembly IDisposable
public sealed class CameraFeedClient : IDisposable

Namespace: AR51.Unity.SDK (transport assembly, separate from .Client).

The caller-facing client for a remote CVS camera-feed endpoint. Obtain one from the live connection — it lets you enumerate remote cameras, fetch their CvsCameraInfo, register a frame listener to receive JPG frames, and drive remote recording.

You don't construct it directly; get it from ServiceManager.Server:

var client = ServiceManager.Server.GetCameraFeedClient(address, port);

GetCameraFeedClient(address, port) is on the transport ServiceContainer exposed by ServiceManager.Server; use CameraService for local device capture, and RenderService to composite a remote feed with holograms.

Units

AR 51 mocap and camera positions are Unity world-space meters; FOV/angle results are in degrees. The CvsCameraInfo extrinsic matrix is the camera's world pose in meters (handedness-corrected — see below).

Lifetime

CameraFeedClient owns a transport connection and implements IDisposable. Dispose() it (or wrap it in using) when you're done so the underlying connection is released.

Properties

PropertyTypeDescription
Endpoint
Addressstringthe remote camera-feed host address
Portintthe remote camera-feed port
EndPointstringthe resolved "address:port" endpoint
IsConnectedbooltrue while the client's transport connection is live

Method summary

Cameras

MethodReturns
GetCameraInfoCvsCameraInfo
GetAvailableCamerasCvsCameraInfo[]
GetAvailableCamerasAsyncTask<CvsCameraInfo[]>async
TryGetRealCameraInfosCvsCameraInfo[]
TryGetRealCameraInfosAsyncTask<CvsCameraInfo[]>async

Frame listeners

MethodReturns
Registervoid
Unregistervoid

Recording

MethodReturns
GetRecordingReadyvoid
StartRecordingAsyncvoidasync
StopRecordingAsyncvoidasync
StopRecordingvoid

Lifetime

MethodReturns
Stopvoid
Disconnectvoid
DisposevoidIDisposable

→ Full descriptions in Method details below.

Method details

GetCameraInfo

method
public CvsCameraInfo GetCameraInfo(string cameraId);

Fetches the current CvsCameraInfo for one camera by id (resolution, frame rate, connection state, and the packed intrinsic/extrinsic matrices).

Parameters
cameraIdstringthe remote camera's Id (see CvsCameraInfo.Id)
ReturnsCvsCameraInfothe camera's info model

GetAvailableCameras

methodasync variant
public CvsCameraInfo[] GetAvailableCameras();
public Task<CvsCameraInfo[]> GetAvailableCamerasAsync();

Enumerates every camera the remote endpoint advertises, including synthetic/relayed cameras. Use the …Async form off the Unity main thread to avoid blocking.

ReturnsCvsCameraInfo[]all advertised cameras
Exampleinferred
var client = ServiceManager.Server.GetCameraFeedClient(address, port);
foreach (CvsCameraInfo cam in client.GetAvailableCameras())
Debug.Log($"{cam.Id}: {cam.Width}x{cam.Height} @ {cam.FrameRate}fps connected={cam.IsConnected}");

TryGetRealCameraInfos

methodasync variant
public CvsCameraInfo[] TryGetRealCameraInfos(); // excludes synthetic/relayed cameras
public Task<CvsCameraInfo[]> TryGetRealCameraInfosAsync();

Like GetAvailableCameras but filtered to real (physical) cameras — synthetic / relayed cameras are excluded. Prefer this when you only want to place or render actual hardware views.

ReturnsCvsCameraInfo[]the physical cameras only

Register

method
public void Register(string cameraId, ICameraFeedListener listener);

Subscribes a listener to a camera's frame stream. The listener receives JPG frames via its OnCameraFeedReceived callback. (ICameraFeedListener is a transport interface — see the Connection area.)

Parameters
cameraIdstringthe camera to subscribe to
listenerICameraFeedListenerreceives JPG frames via OnCameraFeedReceived
Exampleinferred
class FeedSink : ICameraFeedListener
{
public void OnCameraFeedReceived(byte[] jpg) { /* decode / display */ }
}

var sink = new FeedSink();
client.Register("cam-0", sink);
// …later
client.Unregister("cam-0", sink);

Unregister

method
public void Unregister(string cameraId, ICameraFeedListener listener);

Removes a previously registered listener from a camera so it stops receiving frames. Pass the same cameraId/listener pair you registered.

GetRecordingReady

method
public void GetRecordingReady(string cameraId, string fileName);

Prepares the remote side to record the named camera into fileName (call before StartRecordingAsync).

Parameters
cameraIdstringthe camera to record
fileNamestringremote output file name for the recording

StartRecordingAsync

methodasync
public void StartRecordingAsync(string cameraId);

Starts remote recording of the camera's feed. Pair with GetRecordingReady (to set the output file) and stop with StopRecording / StopRecordingAsync.

Parameters
cameraIdstringthe camera to start recording
Exampleinferred
client.GetRecordingReady("cam-0", "session-01.mp4");
client.StartRecordingAsync("cam-0");
// …later
client.StopRecording("cam-0");

StopRecording

methodasync variant
public void StopRecording(string cameraId);
public void StopRecordingAsync(string cameraId);

Stops a recording started with StartRecordingAsync. Use the …Async variant when you don't want to block the caller.

Parameters
cameraIdstringthe camera to stop recording

Stop

method
public void Stop();

Stops the client's active feed/recording work without tearing down the connection.

Disconnect

method
public void Disconnect();

Closes the transport connection to the remote camera-feed endpoint. After this, IsConnected is false.

Dispose

methodIDisposable
public void Dispose();

Releases the client and its underlying connection. Call when you're done, or use a using block. After disposal the instance must not be reused.

Exampleinferred
using var client = ServiceManager.Server.GetCameraFeedClient(address, port);
var cams = client.GetAvailableCameras();
// client is disposed at end of scope

CvsCameraInfo

proto message · transport
message CvsCameraInfo

Namespace: AR51.GRPC.CVS (proto-generated, in the transport assembly).

The camera data model the client receives via CameraFeedClient and RenderService. It carries the camera's identity, resolution, frame rate, connection state, and packed intrinsic/extrinsic/distortion matrices.

Transport type — use the Extensions helpers

Because CvsCameraInfo is a generated proto type, its matrices arrive as packed bytes. Don't unpack them by hand — the documented, usable API is the Extensions helpers below, which return Unity Matrix4x4/FOV values.

Fields

FieldTypeDescription
Identity
Idstringcamera identifier
CameraTypestringcamera type label
Image
Widthint32image width in pixels
Heightint32image height in pixels
FrameRateint32frames per second
State
IsConnectedboolwhether the camera is currently connected
IsRemoteboolwhether the camera is relayed from a remote source
RemoteEndpointstringendpoint of the remote source (when IsRemote)
Calibration (packed)
Intrisicbytes4×4 intrinsic matrix, row-major float[16] (packed) — [sic] spelling
Extrensicbytes4×4 extrinsic (camera pose) matrix, float[16] (packed) — [sic] spelling
Distortionbytesdistortion coefficients (packed)

⚠️ The Intrisic and Extrensic field names are misspelled in the proto [sic] — preserved here because that's the wire name you'll see on the type. Read them through the helpers below rather than touching the raw bytes.

Extensions helpers (on CvsCameraInfo)

public static class Extensions — namespace AR51.Unity.SDK. These unpack the packed matrices into Unity types and are the documented, usable API for CvsCameraInfo. See the full helper list on the Extensions page.

public static Matrix4x4 GetIntrisic(this CvsCameraInfo info); // unpacks Intrisic → Unity Matrix4x4
public static Matrix4x4 GetExtrinsic(this CvsCameraInfo info); // unpacks Extrensic, handedness-corrected
public static float GetVerticalFOV(this CvsCameraInfo info); // degrees, from Height & fy
public static float GetHorizontalFOV(this CvsCameraInfo info); // degrees, from Width & fx
  • GetIntrisic — unpacks Intrisic into a Unity Matrix4x4. It's a pinhole 3×3 embedded in a 4×4: fx = [0,0], fy = [1,1]. (Method name preserves the proto [sic] spelling.)
  • GetExtrinsic — unpacks Extrensic (the camera's world pose) into a Matrix4x4, rotated 180° about Z to map the CVS y-up / right-handed convention into Unity. Translation is in meters.
  • GetVerticalFOV — vertical field of view in degrees, derived from Height and fy.
  • GetHorizontalFOV — horizontal field of view in degrees, derived from Width and fx.
Exampleinferred
CvsCameraInfo cam = client.GetCameraInfo("cam-0");

Matrix4x4 intrinsic = cam.GetIntrisic(); // [sic] proto spelling
Matrix4x4 worldPose = cam.GetExtrinsic(); // handedness-corrected; translation in meters
float vFov = cam.GetVerticalFOV(); // degrees
float hFov = cam.GetHorizontalFOV(); // degrees

// Place a Unity camera at the CVS camera's pose:
renderCamera.transform.position = worldPose.GetColumn(3);
renderCamera.fieldOfView = vFov; // Unity uses vertical FOV

See also

  • ServiceManager — provides Server.GetCameraFeedClient(address, port)
  • RenderService — composites a remote CvsCameraInfo feed with holograms, using these matrix/FOV helpers
  • CameraService — local device capture (the counterpart to this remote client)
  • Extensions — the full set of CvsCameraInfo and Core↔Unity helpers
  • Connection & ServicesServiceNames.CameraFeedService, discovery, and the transport overview
  • Class index — all Unity SDK types
Was this page helpful?