CameraService
public sealed class CameraService : Singleton<CameraService>, ICameraService
Namespace: AR51.Unity.SDK · Inherits: Singleton<CameraService> (a Unity MonoBehaviour) · implements ICameraService
Controls this device's local camera capture and streaming — used when the Unity instance is itself acting as a capture device. Drop the component on a GameObject, call StartStreaming to begin capture, then pull frames off the collection returned by GetFeed. Backed by an internal device CameraAdapter.
Pixel dimensions (width/height, PreviewWidth/PreviewHeight) are in pixels; fps is frames/second; jpgQuality is 0–100. AR 51 spatial data elsewhere in the SDK is in meters — CameraService itself carries no spatial units.
CameraService's CameraAdapters (and the NatDevice integration) are device-capture / third-party plumbing for grabbing frames from the local camera hardware. They are not part of the documented public surface — use the properties and methods below instead.
Properties
| Property | Type | Access | Description |
|---|---|---|---|
| Capture state | |||
IsStreaming | bool | get | true while capture/streaming is active |
Frame | Texture | get | the latest captured frame |
HologramsEnabled | bool | get / set | composite holograms into the captured frame |
Recorder | IVideoRecorder | get | the active video recorder, if any |
Characteristics | ICameraCharacteristics | get | static capabilities of the backing camera |
| Scene references | |||
MainCamera | Camera | field | scene main-camera reference |
NoFeedDefault | Texture2D | field | fallback texture shown when there is no feed |
NoFeedDefaultJpg | byte[] | field | fallback JPG bytes when there is no feed |
| Preview | |||
PreviewWidth | int | get / set | preview width in pixels |
PreviewHeight | int | get / set | preview height in pixels |
| Exposure | |||
ExposureLock | bool | get / set | lock auto-exposure |
ExposureBias | float | get / set | exposure-bias value (clamped to the min/max below) |
ExposureBiasMin | float | get | minimum supported exposure bias |
ExposureBiasMax | float | get | maximum supported exposure bias |
| Focus | |||
AutoFocus | bool | get / set | enable continuous auto-focus |
Method summary
| Method | Returns | |
|---|---|---|
StartStreaming | void | instance |
SuspendStreaming | void | instance |
ResumeStreaming | void | instance |
StopStreaming | void | instance |
GetFeed | BlockingCollection<CameraFrame> | instance |
StartTestStreaming | void | instance |
→ Full descriptions in Method details below.
Method details
StartStreaming
public void StartStreaming(int width, int height, int fps, int jpgQuality, bool hologramsEnabled);
Begins camera capture/streaming. After calling this, read frames off the collection returned by GetFeed.
0–100HologramsEnabled)var cam = CameraService.Instance; // Singleton<CameraService>
cam.StartStreaming(1280, 720, 30, 80, hologramsEnabled: true);
var feed = cam.GetFeed();
foreach (CameraFrame frame in feed.GetConsumingEnumerable())
{
// process each captured frame (e.g. frame.Jpg)
}
SuspendStreaming
public void SuspendStreaming();
Pauses capture without tearing it down. Pair with ResumeStreaming to continue with the same configuration (e.g. across an application-pause). IsStreaming reflects the suspended state.
ResumeStreaming
public void ResumeStreaming();
Resumes capture previously paused with SuspendStreaming.
StopStreaming
public void StopStreaming();
Stops capture and tears down the stream. After this, IsStreaming is false and GetFeed no longer yields new frames.
GetFeed
public BlockingCollection<CameraFrame> GetFeed();
The frame queue for the active stream. Pull frames off it (e.g. with GetConsumingEnumerable()); each item is a CameraFrame. Call after StartStreaming (or StartTestStreaming).
StartTestStreaming
public void StartTestStreaming();
Convenience entry point for testing: starts streaming at 1280×720 @ 30 fps, quality 100. Equivalent to calling StartStreaming with those values. Read the result via GetFeed.
See also
CameraFeedClient— the client for consuming a remote CVS camera feed (this class is for the local device camera)RenderService— renders and re-encodes a remote camera's composited feed- Connection & Services —
CameraFrame,IVideoRecorder,ICameraCharacteristics, and the service entry points - Class index — all Unity SDK types