Camera¶
Camera config, frames, streaming sessions, detection events, runtime device API.
camera_ui_sdk.camera ¶
CameraPublicProperties
module-attribute
¶
CameraPublicProperties = Literal['_id', 'nativeId', 'pluginInfo', 'name', 'disabled', 'isCloud', 'info', 'type', 'snapshotSettings', 'zones', 'detectionSettings', 'ptzAutotrack', 'frameWorkerSettings', 'interfaceSettings', 'recordingSettings', 'plugins', 'assignments', 'sources']
Camera public property names for observation.
AlertZoneMatch
module-attribute
¶
When an object counts as inside an alert zone: where it stands, touching, or fully inside.
TimeWindow
module-attribute
¶
A daily time window ("HH:mm"), read in the timezone it was configured in. A to before from wraps around midnight.
CameraImplementation
module-attribute
¶
Value accepted by CameraDevice.implement: streaming, snapshot, or both.
EVENT_TRIGGER_TYPES
module-attribute
¶
EVENT_TRIGGER_TYPES: tuple[str, ...] = ('motion', 'audio', 'contact', 'doorbell', 'switch', 'light', 'siren', 'security_system', 'line-crossing')
All event trigger types as a runtime-accessible tuple.
AudioCodec
module-attribute
¶
AudioCodec = Literal['PCMU', 'PCMA', 'MPEG4-GENERIC', 'opus', 'G722', 'G726', 'MPA', 'PCM', 'FLAC', 'ELD', 'PCML', 'L16']
Supported audio codecs (RTP/SDP format names).
AudioFFmpegCodec
module-attribute
¶
AudioFFmpegCodec = Literal['pcm_mulaw', 'pcm_alaw', 'aac', 'libopus', 'g722', 'g726', 'mp3', 'pcm_s16be', 'pcm_s16le', 'flac']
FFmpeg audio codec names for transcoding.
CameraActivityMode
module-attribute
¶
When the live stream runs: continuously, only during activity, or on demand.
CameraAspectRatio
module-attribute
¶
Camera aspect ratio for UI display: a preset or any custom width:height ratio.
CameraAspectRatioPreset
module-attribute
¶
Built-in aspect ratio presets offered as quick picks in the UI.
CameraRole
module-attribute
¶
Camera stream resolution role. Used to identify different quality streams from the same camera.
CameraType
module-attribute
¶
Camera device type.
- camera: Standard surveillance camera
- doorbell: Doorbell camera
DetectionEventState
module-attribute
¶
Event lifecycle state.
DetectionEventType
module-attribute
¶
DetectionEventType = Literal['start', 'end', 'update', 'segment-start', 'segment-update', 'segment-end']
Detection event message type (lifecycle phase).
EventTriggerType
module-attribute
¶
EventTriggerType = Literal['motion', 'audio', 'contact', 'doorbell', 'switch', 'light', 'siren', 'security_system', 'line-crossing']
Event trigger type.
LineDirection
module-attribute
¶
Line crossing direction filter.
- both: Trigger on crossings in either direction
- a-to-b: Trigger only when crossing from A side to B side
- b-to-a: Trigger only when crossing from B side to A side
MotionResolution
module-attribute
¶
Motion detection resolution setting. Higher resolution = more accurate but slower.
PlaybackSource
module-attribute
¶
Recorded playback quality selection: a fixed tier, or automatic tier choice from the recorded coverage.
Point
module-attribute
¶
Zone polygon coordinate as [x, y] tuple (0-100 percentage).
ProbeAudioCodec
module-attribute
¶
Audio codecs supported for stream probing.
RTSPAudioCodec
module-attribute
¶
Audio codecs supported for RTSP streaming.
StreamDirection
module-attribute
¶
Stream direction (from SDP).
StreamingRole
module-attribute
¶
Streaming roles (excludes snapshot).
VideoCodec
module-attribute
¶
Supported video codecs (RTP/SDP format names).
VideoFFmpegCodec
module-attribute
¶
FFmpeg video codec names for transcoding.
VideoStreamingMode
module-attribute
¶
Video streaming mode for UI playback.
- auto: Automatically select best method
- webrtc: WebRTC with UDP (lowest latency)
- webrtc/tcp: WebRTC with TCP fallback
- mse: Media Source Extensions (browser native)
ZoneType
module-attribute
¶
Detection zone intersection type.
- intersect: Trigger when object overlaps the zone at all
- contain: Trigger only when object is fully inside the zone
FrameWorkerDecoderHardware
module-attribute
¶
FrameWorkerDecoderHardware = Literal['auto', 'cpu', 'cuda', 'vaapi', 'qsv', 'videotoolbox', 'd3d11va', 'd3d12va', 'dxva2', 'vulkan', 'opencl', 'drm', 'rkmpp']
Hardware backend for the detection decoder. auto probes the platform order, cpu forces software decoding.
NotificationSpeed
module-attribute
¶
How long a push waits for a good picture.
- immediate: send right away, with a picture only if one is ready
- balanced: wait up to 2 seconds for the best picture
- best: wait up to 4 seconds for the best picture
RecordingMode
module-attribute
¶
How recordings are captured.
- continuous: record around the clock
- event: record only around detections, padded by the pre-buffer
- adhoc: record only when started manually
RecordingSource
module-attribute
¶
Stream tier to record.
AssignedPlugin ¶
BaseCamera ¶
Bases: TypedDict
Base camera data structure (stored in database).
zones
instance-attribute
¶
Zone configurations, one list per purpose.
detectionSettings
instance-attribute
¶
Detection settings.
recordingSettings
instance-attribute
¶
Recording settings.
notificationSettings
instance-attribute
¶
Push notification settings.
frameWorkerSettings
instance-attribute
¶
Frame worker settings.
BaseCameraConfig ¶
Bases: TypedDict
Base camera configuration (shared fields).
Camera ¶
CameraConfig ¶
CameraConfigInputSettings ¶
Bases: TypedDict
Camera input settings for config.
preload
instance-attribute
¶
Keep a keyframe cache for this source, so the view opens faster. Use hotMode to keep the stream connected.
muted
instance-attribute
¶
Strip the audio track from this source (defaults to False).
childSourceId
instance-attribute
¶
Child source ID (for snapshot fallback).
urls
instance-attribute
¶
Raw source URLs, the server resolves them into streaming URLs.
CameraInformation ¶
Bases: TypedDict
Camera hardware/firmware information.
CameraInput ¶
Bases: TypedDict
Camera video input/source with resolved URLs.
preload
instance-attribute
¶
Keep a keyframe cache for this source, so the view opens faster. Use hotMode to keep the stream connected.
muted
instance-attribute
¶
Strip the audio track from this source (defaults to False).
videoCodec
instance-attribute
¶
Probed video codec of this source. Filled by the server once the stream has been probed; absent until then.
audioCodecs
instance-attribute
¶
Probed audio codecs of this source (camera to client, deduplicated, in track order). Filled by the server once the stream has been probed; absent until then.
backchannelAudioCodec
instance-attribute
¶
Probed talkback audio codec (client to camera). Present only when the probed source has a backchannel.
childSourceId
instance-attribute
¶
Child source ID (for snapshot fallback).
CameraPluginInfo ¶
CameraPropertyObservableObject ¶
CameraUiSettings ¶
PluginAssignments ¶
Bases: TypedDict
Plugin assignments for a camera, keyed by sensor type.
Single-provider sensors and the camera controller hold one plugin; multi-provider sensors and the hub hold a list.
AlertZone ¶
Bases: TypedDict
Alert zone configuration. Never filters detections: a label selected here only sends push notifications while an object of that label is inside the zone.
labels
instance-attribute
¶
Labels that alert from inside this zone (empty = every label alerts here).
faces
instance-attribute
¶
Faces that may push from inside this zone. Missing leaves faces out of the
decision, an empty list lets every recognized face push, otherwise only the
listed identities do. unknown covers everyone the recognition could not
name, including people whose face was never captured.
plates
instance-attribute
¶
Plates that may push from inside this zone, same rules as faces. Plates
are OCR text, so the list is free-form rather than picked from a roster.
AudioDetectionSettings ¶
CameraDetectionSettings ¶
CameraZones ¶
Bases: TypedDict
Everything the zone editor draws, one list per purpose. Motion decides where frame motion counts, object which types count where, privacy where nothing is looked at, alert which types notify from where, and lines report objects crossing them.
DetectionLine ¶
Bases: TypedDict
Detection line configuration. Defines a virtual tripwire for line crossing detection. The two points define grab-handle positions; the actual crossing line is perpendicular through their midpoint.
points
instance-attribute
¶
Grab-handle positions (0-100%). Crossing line is perpendicular through midpoint.
FaceDetectionSettings ¶
Bases: TypedDict
Face detection settings.
LicensePlateDetectionSettings ¶
Bases: TypedDict
License plate detection settings.
confidence
instance-attribute
¶
Minimum confidence threshold (0 - 1) for a plate to be found in the picture.
ocrConfidence
instance-attribute
¶
Minimum text recognition confidence (0 - 1) for a plate read to count.
minLength
instance-attribute
¶
Minimum plate text length, shorter reads are dropped as fragments.
MotionDetectionSettings ¶
MotionZone ¶
Bases: TypedDict
Motion zone configuration. Motion carries no labels, so a motion zone only says where frame motion counts. No motion zone at all means motion counts everywhere.
ObjectDetectionSettings ¶
Bases: TypedDict
Object detection settings.
confidences
instance-attribute
¶
Minimum confidence threshold (0.3 - 1.0) per object label.
suppressStatic
instance-attribute
¶
Suppress events from objects that stay stationary across events (e.g. parked cars). Defaults to True.
timeout
instance-attribute
¶
Object dwell time in seconds for camera-based object sensors that report a detection without a matching end report. Frame-based detection ignores this. Defaults to 15.
ObjectZone ¶
Bases: TypedDict
Object zone configuration. With at least one include object zone, an object counts only inside such a zone and only when its label is listed there.
labels
instance-attribute
¶
Labels that count in this zone. Besides the detection labels, face and
license_plate decide whether an object here is identified at all, so a zone
can watch a street without recognizing anyone on it.
PrivacyZone ¶
Bases: TypedDict
Privacy zone configuration. camera.ui always covers the area in live view, playback and the pictures it generates; dropDetections decides whether detections inside are dropped too.
PtzAutotrackSettings ¶
Bases: TypedDict
PTZ autotracking settings: the camera follows detected objects automatically.
targetLabels
instance-attribute
¶
Object labels to track (e.g. 'person', 'vehicle').
minConfidence
instance-attribute
¶
Minimum detection confidence to track (0.3 - 1.0).
triggerDeadZone
instance-attribute
¶
Dead zone around frame center (0 - 0.3). No motor command while the target is inside this zone.
trackingSpeed
instance-attribute
¶
How aggressively the camera moves to re-center the target (1 - 5). Higher reaches full pan/tilt speed at a smaller off-center error.
leadMs
instance-attribute
¶
Motion prediction (0 - 4000): aim this many milliseconds ahead along the target's measured velocity, covering the time the camera needs to move and settle. 0 disables prediction.
panRate
instance-attribute
¶
Camera pan-rate calibration (0.1 - 3): assumed pan travel at full motor speed in normalized frame-widths per second. Lower it if the camera stops short of the target, raise it if it overshoots.
returnToHome
instance-attribute
¶
Return to home position when no target is found for homeWaitMs.
homeWaitMs
instance-attribute
¶
How long to wait (ms) without a target before returning home.
minTargetSize
instance-attribute
¶
Smallest target to start following, as a fraction of the frame height (0 - 0.5). 0 disables the limit.
maxTargetSize
instance-attribute
¶
Largest target to keep following, as a fraction of the frame height (0 - 1). Above it the camera holds its position. 0 disables the limit.
activeHours
instance-attribute
¶
Hours the camera is allowed to follow. Outside them autotracking rests.
SensorTriggerSettings ¶
CameraDevice ¶
Bases: Protocol
Main camera device interface. Provides access to camera streams, sensors, and services.
frameWorkerSettings
property
¶
Frame worker settings.
highResolutionSource
property
¶
High resolution source (if available).
midResolutionSource
property
¶
Mid resolution source (if available).
lowResolutionSource
property
¶
Low resolution source (if available).
onFrameWorkerConnected
property
¶
Observable for frame worker state changes.
onDetectionEvent
property
¶
Observable for detection events.
Emits 'start', 'update', 'end', 'segment-start', 'segment-update' and 'segment-end'. Segments ride on the segment-* messages only, thumbnails on 'segment-start' and 'segment-end'.
getSourceById ¶
Get a source by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The source ID. |
required |
Returns:
| Type | Description |
|---|---|
CameraDeviceSource | None
|
The matching source, or None if not found. |
createStorage ¶
Create storage for plugin-specific camera configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schemas
|
list[JsonSchema]
|
Schema definitions for the storage. |
required |
Returns:
| Type | Description |
|---|---|
DeviceStorage
|
Typed device storage instance. |
connect
async
¶
Tell the server this camera is online.
Only the plugin that owns this camera (via pluginInfo) may connect it.
disconnect
async
¶
Tell the server this camera is offline.
Only the plugin that owns this camera (via pluginInfo) may disconnect it.
onPropertyChange ¶
onPropertyChange(property: CameraPublicProperties | list[CameraPublicProperties]) -> Observable[CameraPropertyObservableObject]
Observe camera property changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
property
|
CameraPublicProperties | list[CameraPublicProperties]
|
Property name(s) to observe. |
required |
Returns:
| Type | Description |
|---|---|
Observable[CameraPropertyObservableObject]
|
Observable emitting old and new values. |
addSensor
async
¶
Register a sensor that belongs to this camera's hardware (spotlight, siren, PTZ, battery, ...). The host assigns it to this camera and reconciles it across restarts like a standalone sensor.
Registering here declares "this sensor belongs to this camera and no
other": the assignment is locked, users cannot re-assign it. For
sensors the user should assign freely, register via
sensorManager.addSensor() instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sensor
|
Sensor[Any, Any, Any]
|
Sensor instance to register. |
required |
removeSensor
async
¶
Unregister a sensor this plugin registered on this camera. The persisted entity stays (shows disconnected) unless the user deletes it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sensorId
|
str
|
ID of sensor to unregister. |
required |
implement
async
¶
Register a camera implementation for streaming and/or snapshot.
The impl value should implement StreamingInterface, SnapshotInterface, or both.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
impl
|
CameraImplementation
|
Object or class implementing camera interfaces. |
required |
CameraDeviceSource ¶
Bases: CameraSource, Protocol
Camera source with full streaming capabilities.
generateRTSPUrl ¶
Generate RTSP URL with specified options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
RTSPUrlOptions | None
|
URL generation options. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
RTSP URL string. |
CameraSource ¶
Bases: Protocol
Camera source with snapshot and probe capabilities.
preload
instance-attribute
¶
Keep a keyframe cache for this source, so the view opens faster. Use hotMode to keep the stream connected.
muted
instance-attribute
¶
Strip the audio track from this source (defaults to False).
childSourceId
instance-attribute
¶
Child source ID (for snapshot fallback).
snapshot
async
¶
Get camera snapshot image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forceNew
|
bool
|
Force fresh snapshot (ignore cache). |
False
|
Returns:
| Type | Description |
|---|---|
bytes | None
|
JPEG image data or None if unavailable. |
probeStream
async
¶
Probe stream for codec and track information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probeConfig
|
ProbeConfig | None
|
What to probe for. |
None
|
refresh
|
bool
|
Force fresh probe (ignore cache). |
False
|
Returns:
| Type | Description |
|---|---|
ProbeStream | None
|
Stream information or None if unavailable. |
getStreamStatus
async
¶
Get the current stream connection status.
Returns:
| Type | Description |
|---|---|
str
|
Status string: 'connected', 'connecting', 'error', or 'idle'. |
generateSnapshotUrl ¶
Generate Snapshot URL with specified options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
SnapshotUrlOptions | None
|
URL generation options. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Snapshot URL string. |
SnapshotInterface ¶
Bases: Protocol
Optional implementation that provides snapshots.
snapshot
async
¶
Get a snapshot image from the camera.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_id
|
str
|
The source ID to get the snapshot from. |
required |
force_new
|
bool
|
If True, bypass cache and get a fresh snapshot. |
False
|
Returns:
| Type | Description |
|---|---|
bytes | None
|
Image data as bytes, or None if unavailable. |
StreamingInterface ¶
Bases: Protocol
Optional implementation that provides stream URLs.
streamUrl
async
¶
Get the streaming URL for a source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_id
|
str
|
The ID of the source. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The streaming URL (e.g. rtsp://, rtmp://, or custom protocol). |
DetectionEvent ¶
Bases: TypedDict
Aggregated detection event with lifecycle (start -> update -> end). Groups individual sensor detections into structured events.
segments
instance-attribute
¶
Detection segments (object detection phases). For segment-* messages: contains only the current segment. For start/end messages: empty.
segmentIndex
instance-attribute
¶
Index of the segment in segments[0] for segment-* messages.
expectedEndTime
instance-attribute
¶
Expected event end time (Unix ms): the latest dwell expiry across all
currently-active triggers. Monotonically non-decreasing during the event
lifetime. Updated on each update / segment-* message.
DetectionEventPayload ¶
EventAttribute ¶
Bases: TypedDict
Unified attribute within a segment (face identity, license plate, classifier result).
EventDetection ¶
Bases: TypedDict
Aggregated object detection within a segment.
moving
instance-attribute
¶
Whether the object was moving (True) or stationary (False).
path
instance-attribute
¶
Where the tracked object entered and left the frame within this segment.
zones
instance-attribute
¶
Names of detection/alert zones any object of this label overlapped during the segment.
alert
instance-attribute
¶
Whether this detection may raise a notification. Alert zones decide it, the camera's own reports pass.
EventSegment ¶
EventTrigger ¶
Bases: TypedDict
Event trigger (motion, audio, sensor, or line-crossing).
CameraFrameWorkerSettings ¶
Bases: TypedDict
Frame worker (decoder) settings.
mainStreamAnalysis
instance-attribute
¶
Analyse the main stream while something is detected, instead of the detection stream.
decoder
instance-attribute
¶
Decoder hardware selection. Applies on the machine that decodes this camera (master or assigned worker); an unusable selection falls back to auto.
workerDecoder
instance-attribute
¶
Decoder hardware selection used instead of decoder while this camera decodes on its assigned worker. Falls back to decoder when omitted.
FrameWorkerDecoderSettings ¶
Bases: TypedDict
Decoder hardware selection for the frame worker.
SnapshotSettings ¶
Bases: TypedDict
Snapshot settings for a camera.
CameraNotificationSettings ¶
Bases: TypedDict
Push notification settings for a camera.
video
instance-attribute
¶
Attach a short clip of the moment. Needs recording, uses the lowest recorded quality.
audio
instance-attribute
¶
Audio events that send a push. other covers custom audio labels.
cooldown
instance-attribute
¶
Minimum seconds between pushes. Critical alerts bypass it and do not count toward it.
CameraRecordingSettings ¶
Bases: TypedDict
Recording settings for a camera.
preBuffer
instance-attribute
¶
Seconds of video kept before an event (event mode, 0 - 60).
AudioCodecProperties ¶
Bases: TypedDict
Audio codec properties from stream probe.
AudioStreamInfo ¶
Bases: TypedDict
Audio stream information from probe.
FMTPInfo ¶
Go2RtcRTSPSource ¶
Bases: TypedDict
RTSP streaming URLs from go2rtc.
Go2RtcSnapshotSource ¶
Go2RtcWSSource ¶
ProbeConfig ¶
Bases: TypedDict
Configuration for stream probing.
ProbeStream ¶
RTSPUrlOptions ¶
SnapshotUrlOptions ¶
Bases: TypedDict
Options for generating snapshot URLs.
hw
instance-attribute
¶
Hardware acceleration backend.
StreamUrls ¶
VideoCodecProperties ¶
VideoStreamInfo ¶
Bases: TypedDict
Video stream information from probe.