Skip to content

@camera.ui/sdk / sensor / ClassifierDetectorSensor

Abstract Class: ClassifierDetectorSensor<TStorage>

Defined in: sensor/classifier.ts:171

Classifier detector that receives video frames from the backend pipeline. Extend this class and implement detectClassifications to run image classification models against trigger regions.

Extends

Type Parameters

TStorage

TStorage extends object = Record<string, any>

Constructors

Constructor

new ClassifierDetectorSensor<TStorage>(name?): ClassifierDetectorSensor<TStorage>

Defined in: sensor/classifier.ts:66

Parameters

name?

string = 'Classifier'

Returns

ClassifierDetectorSensor<TStorage>

Inherited from

ClassifierSensor.constructor

Properties

_requiresFrames

_requiresFrames: boolean = true

Defined in: sensor/classifier.ts:172

Overrides

ClassifierSensor._requiresFrames


category

readonly category: Sensor = SensorCategory.Sensor

Defined in: sensor/classifier.ts:62

Inherited from

ClassifierSensor.category


id

readonly id: string

Defined in: sensor/base.ts:190

Inherited from

ClassifierSensor.id


name

readonly name: string

Defined in: sensor/base.ts:189

Inherited from

ClassifierSensor.name


onAssignmentChanged

readonly onAssignmentChanged: Observable<boolean>

Defined in: sensor/base.ts:209

Inherited from

ClassifierSensor.onAssignmentChanged


onCapabilitiesChanged

readonly onCapabilitiesChanged: Observable<string[]>

Defined in: sensor/base.ts:200

Observable for capability changes. Emits the full capabilities array when capabilities change.

Inherited from

ClassifierSensor.onCapabilitiesChanged


onPropertyChanged

readonly onPropertyChanged: Observable<PropertyChangeOf<ClassifierSensorProperties>>

Defined in: sensor/base.ts:198

Observable for property changes. Emits { property, value, timestamp } when any property changes.

Inherited from

ClassifierSensor.onPropertyChanged


type

readonly type: Classifier = SensorType.Classifier

Defined in: sensor/classifier.ts:61

Inherited from

ClassifierSensor.type

Accessors

cameraId

Get Signature

get cameraId(): string

Defined in: sensor/base.ts:257

Camera ID this sensor belongs to. Throws if sensor not yet added to a camera.

Returns

string

Inherited from

ClassifierSensor.cameraId


capabilities

Get Signature

get capabilities(): TCapability[]

Defined in: sensor/base.ts:277

Optional feature flags advertised by this sensor (e.g., PTZ pan/tilt/zoom)

Returns

TCapability[]

Set Signature

set capabilities(value): void

Defined in: sensor/base.ts:282

Set capabilities and notify the backend. Automatically deduplicates.

Parameters
value

TCapability[]

Returns

void

Inherited from

ClassifierSensor.capabilities


detected

Get Signature

get detected(): boolean

Defined in: sensor/classifier.ts:77

Whether any classification result is active.

Returns

boolean

Inherited from

ClassifierSensor.detected


detections

Get Signature

get detections(): ClassifierDetection[]

Defined in: sensor/classifier.ts:82

Current detection list.

Returns

ClassifierDetection[]

Inherited from

ClassifierSensor.detections


displayName

Get Signature

get displayName(): string

Defined in: sensor/base.ts:233

Returns

string

Inherited from

ClassifierSensor.displayName


isAssigned

Get Signature

get isAssigned(): boolean

Defined in: sensor/base.ts:252

Whether this sensor has been assigned to a camera in the backend

Returns

boolean

Inherited from

ClassifierSensor.isAssigned


labels

Get Signature

get labels(): string[]

Defined in: sensor/classifier.ts:87

Unique labels of the current detections.

Returns

string[]

Inherited from

ClassifierSensor.labels


modelSpec

Get Signature

get abstract modelSpec(): ModelSpec

Defined in: sensor/classifier.ts:175

Declares the expected input dimensions and trigger labels. The backend scales frames to match.

Returns

ModelSpec


pluginId

Get Signature

get pluginId(): string | undefined

Defined in: sensor/base.ts:264

Returns

string | undefined

Inherited from

ClassifierSensor.pluginId


props

Get Signature

get protected props(): Readonly<TProperties>

Defined in: sensor/base.ts:295

Read-only access to the internal property store. Subclasses use this to read current state when implementing semantic methods (e.g., if (this.blocked) return).

Returns

Readonly<TProperties>

Inherited from

ClassifierSensor.props


storage

Get Signature

get storage(): DeviceStorage<TStorage>

Defined in: sensor/base.ts:269

Per-sensor persistent storage. Throws if sensor not yet added to a camera.

Returns

DeviceStorage<TStorage>

Inherited from

ClassifierSensor.storage


storageSchema

Get Signature

get storageSchema(): JsonSchema[]

Defined in: sensor/base.ts:216

Override to provide a JSON schema for per-sensor storage settings UI

Returns

JsonSchema[]

Inherited from

ClassifierSensor.storageSchema

Methods

clearDetections()

clearDetections(): void

Defined in: sensor/classifier.ts:136

Explicitly clear classifier state (detected = false, detections = [], labels = []).

Returns

void

Example

ts
sensor.clearDetections();

Inherited from

ClassifierSensor.clearDetections


detectClassifications()

abstract detectClassifications(frames): Promise<ClassifierResult[]>

Defined in: sensor/classifier.ts:182

Classify frames in batch. Each frame is a pre-cropped, pre-scaled trigger region produced by the upstream object detector. Must return exactly one ClassifierResult per input frame, in the same order.

Parameters

frames

VideoFrameData[]

Returns

Promise<ClassifierResult[]>


getValue()

Call Signature

getValue<K>(property): ClassifierSensorProperties[K] | undefined

Defined in: sensor/base.ts:303

Get the current value of a sensor property. Type-safe via the generic overload — call with a property enum value to get a properly typed result.

Type Parameters
K

K extends keyof ClassifierSensorProperties

Parameters
property

K

Returns

ClassifierSensorProperties[K] | undefined

Inherited from

ClassifierSensor.getValue

Call Signature

getValue(property): unknown

Defined in: sensor/base.ts:304

Get the current value of a sensor property. Type-safe via the generic overload — call with a property enum value to get a properly typed result.

Parameters
property

string

Returns

unknown

Inherited from

ClassifierSensor.getValue


getValues()

getValues(): Readonly<TProperties>

Defined in: sensor/base.ts:320

Get a read-only snapshot of all property values.

Returns

Readonly<TProperties>

Frozen view of every property currently held by the sensor.

Example

ts
const snapshot = sensor.getValues();
console.log(snapshot);

Inherited from

ClassifierSensor.getValues


hasCapability()

hasCapability(capability): boolean

Defined in: sensor/base.ts:423

Parameters

capability

string

Returns

boolean

Inherited from

ClassifierSensor.hasCapability


onAssigned()

protected onAssigned(): void | Promise<void>

Defined in: sensor/base.ts:473

Lifecycle hook: the sensor just became assigned to a camera. Override to start background work that should only run while this sensor is live — polling loops, event subscriptions, timers, external connections.

Called AFTER cameraId, storage, and RPC channels are wired up, so the override can safely access this.cameraId, this.storage, and publish properties via the semantic helper methods.

Errors thrown here are caught and logged — they will NOT break assignment bookkeeping. If your work can fail, handle it inside the override.

Paired 1:1 with onDeassigned — for every onAssigned call there is exactly one matching onDeassigned later (on deassignment or cleanup).

Default: no-op. Most sensors don't need lifecycle hooks.

Returns

void | Promise<void>

Example

ts
protected override async onAssigned(): Promise<void> {
  this._timer = setInterval(() => this.poll(), 5_000);
}

Inherited from

ClassifierSensor.onAssigned


onDeassigned()

protected onDeassigned(): void | Promise<void>

Defined in: sensor/base.ts:493

Lifecycle hook: the sensor is being deassigned. Override to tear down whatever was started in onAssigned — clear timers, close subscriptions, release external resources.

Always called exactly once for each prior onAssigned. Also called from _cleanup if the sensor is being removed while still assigned, so you can rely on this as the single teardown point.

Default: no-op.

Returns

void | Promise<void>

Example

ts
protected override onDeassigned(): void {
  if (this._timer) clearInterval(this._timer);
}

Inherited from

ClassifierSensor.onDeassigned


reportDetections()

reportDetections(detected, detections?): void

Defined in: sensor/classifier.ts:118

Report classification results. Auto-derives detected and labels from the list.

  • reportDetections(true) — generic classification trigger. The SDK synthesizes a single full-frame detection with empty attribute/subAttribute.
  • reportDetections(true, [...]) — explicit classifier detections.
  • reportDetections(false) — clear.

Parameters

detected

boolean

Whether any classification result is active.

detections?

ClassifierDetection[]

Optional explicit classifier detections to publish.

Returns

void

Example

ts
import type { ClassifierDetection } from '@camera.ui/sdk';
sensor.reportDetections(true, [
  {
    label: 'animal',
    confidence: 0.88,
    box: { x: 0.1, y: 0.2, width: 0.3, height: 0.4 },
    attribute: 'bird',
    subAttribute: 'woodpecker',
  } satisfies ClassifierDetection,
]);
sensor.reportDetections(false);

Inherited from

ClassifierSensor.reportDetections


setDisplayName()

setDisplayName(value): void

Defined in: sensor/base.ts:247

Set the display name (the only mutable identifier on a sensor).

Parameters

value

string

Human-readable label shown in the UI.

Returns

void

Example

ts
sensor.setDisplayName('Front Door Motion');

Inherited from

ClassifierSensor.setDisplayName