@camera.ui/sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/CONTRIBUTING.md +1 -0
  3. package/LICENSE.md +22 -0
  4. package/README.md +5 -0
  5. package/dist/camera/config.js +1 -0
  6. package/dist/camera/detection.js +1 -0
  7. package/dist/camera/device.js +1 -0
  8. package/dist/camera/index.js +5 -0
  9. package/dist/camera/streaming.js +1 -0
  10. package/dist/camera/types.js +1 -0
  11. package/dist/external.js +1 -0
  12. package/dist/index.d.ts +5042 -0
  13. package/dist/index.js +16 -0
  14. package/dist/manager/index.js +1 -0
  15. package/dist/manager/types.js +1 -0
  16. package/dist/plugin/contract.js +120 -0
  17. package/dist/plugin/index.js +3 -0
  18. package/dist/plugin/interfaces.js +1 -0
  19. package/dist/plugin/types.js +1 -0
  20. package/dist/sensor/audio.js +118 -0
  21. package/dist/sensor/base.js +460 -0
  22. package/dist/sensor/battery.js +101 -0
  23. package/dist/sensor/contact.js +33 -0
  24. package/dist/sensor/doorbell.js +63 -0
  25. package/dist/sensor/face.js +124 -0
  26. package/dist/sensor/guards.js +133 -0
  27. package/dist/sensor/index.js +19 -0
  28. package/dist/sensor/licensePlate.js +116 -0
  29. package/dist/sensor/light.js +66 -0
  30. package/dist/sensor/motion.js +103 -0
  31. package/dist/sensor/object.js +137 -0
  32. package/dist/sensor/ptz.js +159 -0
  33. package/dist/sensor/siren.js +73 -0
  34. package/dist/sensor/types.js +46 -0
  35. package/dist/service/base.js +96 -0
  36. package/dist/service/index.js +3 -0
  37. package/dist/service/services.js +1 -0
  38. package/dist/service/types.js +1 -0
  39. package/dist/storage/index.js +2 -0
  40. package/dist/storage/schema.js +1 -0
  41. package/dist/storage/storages.js +1 -0
  42. package/package.json +61 -0
  43. package/tsconfig.node.json +30 -0
@@ -0,0 +1,124 @@
1
+ import { Sensor } from './base.js';
2
+ import { SensorCategory, SensorType } from './types.js';
3
+ /**
4
+ * Face sensor property keys
5
+ */
6
+ export var FaceProperty;
7
+ (function (FaceProperty) {
8
+ FaceProperty["Detected"] = "detected";
9
+ FaceProperty["Faces"] = "faces";
10
+ })(FaceProperty || (FaceProperty = {}));
11
+ /**
12
+ * Face Sensor (Specialized)
13
+ *
14
+ * Detects and recognizes faces in camera frames.
15
+ * Can optionally receive person regions from ObjectSensor for focused detection.
16
+ */
17
+ export class FaceSensor extends Sensor {
18
+ type = SensorType.Face;
19
+ category = SensorCategory.Sensor;
20
+ name;
21
+ constructor(name = 'Face Sensor') {
22
+ super();
23
+ this.name = name;
24
+ // Initialize defaults
25
+ this.props.detected = false;
26
+ this.props.faces = [];
27
+ }
28
+ // ========== Properties (Getter/Setter Pairs) ==========
29
+ /** Whether faces are currently detected */
30
+ get detected() {
31
+ return this.rawProps.detected;
32
+ }
33
+ /** Set face detected state */
34
+ set detected(value) {
35
+ this.props.detected = value;
36
+ }
37
+ /** Current face detections */
38
+ get faces() {
39
+ return this.rawProps.faces;
40
+ }
41
+ /** Set face detections */
42
+ set faces(value) {
43
+ this.props.faces = value;
44
+ }
45
+ /**
46
+ * Update face detection state
47
+ *
48
+ * @param detected - Whether faces are detected
49
+ *
50
+ * @param faces - Array of face detections
51
+ */
52
+ setFaces(detected, faces = []) {
53
+ this.props.detected = detected;
54
+ this.props.faces = faces;
55
+ }
56
+ /** Clear face detection state */
57
+ clearFaces() {
58
+ this.props.detected = false;
59
+ this.props.faces = [];
60
+ }
61
+ /**
62
+ * Get faces with known identity
63
+ *
64
+ * @returns Array of recognized faces
65
+ */
66
+ getKnownFaces() {
67
+ return this.faces.filter((f) => f.identity !== undefined);
68
+ }
69
+ /**
70
+ * Get faces without known identity
71
+ *
72
+ * @returns Array of unrecognized faces
73
+ */
74
+ getUnknownFaces() {
75
+ return this.faces.filter((f) => f.identity === undefined);
76
+ }
77
+ /**
78
+ * Check if specific identity is detected
79
+ *
80
+ * @param identity - Identity label to check
81
+ *
82
+ * @returns True if identity is detected, false otherwise
83
+ */
84
+ hasIdentity(identity) {
85
+ return this.faces.some((f) => f.identity === identity);
86
+ }
87
+ }
88
+ /**
89
+ * Face Detector Sensor (Active Detection)
90
+ *
91
+ * Use this class for frame-based face detection (face-api.js, DeepFace, etc.)
92
+ * The `inputProperties` getter specifies the required input format.
93
+ *
94
+ * Receives cropped person regions from ObjectDetectorSensor for efficient processing.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * class FaceAPIDetector extends FaceDetectorSensor {
99
+ * get inputProperties(): VideoInputProperties {
100
+ * return { width: 160, height: 160, format: 'rgb' };
101
+ * }
102
+ *
103
+ * async detectFaces(frame: VideoFrameData, personRegions?: Detection[]): Promise<FaceResult> {
104
+ * const detections = await faceapi.detectAllFaces(frame.data);
105
+ * return {
106
+ * detected: detections.length > 0,
107
+ * faces: detections.map(d => ({
108
+ * label: 'face',
109
+ * confidence: d.score,
110
+ * box: d.box,
111
+ * identity: d.identity,
112
+ * })),
113
+ * };
114
+ * }
115
+ * }
116
+ * ```
117
+ */
118
+ export class FaceDetectorSensor extends FaceSensor {
119
+ /**
120
+ * Indicates this sensor requires video frames for detection.
121
+ * Used by the backend to determine streaming requirements.
122
+ */
123
+ _requiresFrames = true;
124
+ }
@@ -0,0 +1,133 @@
1
+ import { SensorType } from './types.js';
2
+ /**
3
+ * Type guard for Motion sensors
4
+ *
5
+ * Narrows a SensorLike to MotionSensorLike for type-safe property access.
6
+ *
7
+ * @param sensor - The sensor to check
8
+ *
9
+ * @returns True if the sensor is a Motion sensor
10
+ */
11
+ export function isMotionSensor(sensor) {
12
+ return sensor.type === SensorType.Motion;
13
+ }
14
+ /**
15
+ * Type guard for Object detection sensors
16
+ *
17
+ * Narrows a SensorLike to ObjectSensorLike for type-safe property access.
18
+ *
19
+ * @param sensor - The sensor to check
20
+ *
21
+ * @returns True if the sensor is an Object sensor
22
+ */
23
+ export function isObjectSensor(sensor) {
24
+ return sensor.type === SensorType.Object;
25
+ }
26
+ /**
27
+ * Type guard for Audio sensors
28
+ *
29
+ * Narrows a SensorLike to AudioSensorLike for type-safe property access.
30
+ *
31
+ * @param sensor - The sensor to check
32
+ *
33
+ * @returns True if the sensor is an Audio sensor
34
+ */
35
+ export function isAudioSensor(sensor) {
36
+ return sensor.type === SensorType.Audio;
37
+ }
38
+ /**
39
+ * Type guard for Face detection sensors
40
+ *
41
+ * Narrows a SensorLike to FaceSensorLike for type-safe property access.
42
+ *
43
+ * @param sensor - The sensor to check
44
+ *
45
+ * @returns True if the sensor is a Face sensor
46
+ */
47
+ export function isFaceSensor(sensor) {
48
+ return sensor.type === SensorType.Face;
49
+ }
50
+ /**
51
+ * Type guard for License Plate detection sensors
52
+ *
53
+ * Narrows a SensorLike to LicensePlateSensorLike for type-safe property access.
54
+ *
55
+ * @param sensor - The sensor to check
56
+ *
57
+ * @returns True if the sensor is a License Plate sensor
58
+ */
59
+ export function isLicensePlateSensor(sensor) {
60
+ return sensor.type === SensorType.LicensePlate;
61
+ }
62
+ /**
63
+ * Type guard for Contact sensors
64
+ *
65
+ * Narrows a SensorLike to ContactSensorLike for type-safe property access.
66
+ *
67
+ * @param sensor - The sensor to check
68
+ *
69
+ * @returns True if the sensor is a Contact sensor
70
+ */
71
+ export function isContactSensor(sensor) {
72
+ return sensor.type === SensorType.Contact;
73
+ }
74
+ /**
75
+ * Type guard for Light controls
76
+ *
77
+ * Narrows a SensorLike to LightControlLike for type-safe property access.
78
+ *
79
+ * @param sensor - The sensor to check
80
+ *
81
+ * @returns True if the sensor is a Light control
82
+ */
83
+ export function isLightControl(sensor) {
84
+ return sensor.type === SensorType.Light;
85
+ }
86
+ /**
87
+ * Type guard for Siren controls
88
+ *
89
+ * Narrows a SensorLike to SirenControlLike for type-safe property access.
90
+ *
91
+ * @param sensor - The sensor to check
92
+ *
93
+ * @returns True if the sensor is a Siren control
94
+ */
95
+ export function isSirenControl(sensor) {
96
+ return sensor.type === SensorType.Siren;
97
+ }
98
+ /**
99
+ * Type guard for PTZ controls
100
+ *
101
+ * Narrows a SensorLike to PTZControlLike for type-safe property access.
102
+ *
103
+ * @param sensor - The sensor to check
104
+ *
105
+ * @returns True if the sensor is a PTZ control
106
+ */
107
+ export function isPTZControl(sensor) {
108
+ return sensor.type === SensorType.PTZ;
109
+ }
110
+ /**
111
+ * Type guard for Doorbell triggers
112
+ *
113
+ * Narrows a SensorLike to DoorbellTriggerLike for type-safe property access.
114
+ *
115
+ * @param sensor - The sensor to check
116
+ *
117
+ * @returns True if the sensor is a Doorbell trigger
118
+ */
119
+ export function isDoorbellTrigger(sensor) {
120
+ return sensor.type === SensorType.Doorbell;
121
+ }
122
+ /**
123
+ * Type guard for Battery info sensors
124
+ *
125
+ * Narrows a SensorLike to BatteryInfoLike for type-safe property access.
126
+ *
127
+ * @param sensor - The sensor to check
128
+ *
129
+ * @returns True if the sensor is a Battery info sensor
130
+ */
131
+ export function isBatteryInfo(sensor) {
132
+ return sensor.type === SensorType.Battery;
133
+ }
@@ -0,0 +1,19 @@
1
+ // Base
2
+ export * from './base.js';
3
+ export * from './types.js';
4
+ export * from './guards.js';
5
+ // Detection Sensors
6
+ export * from './audio.js';
7
+ export * from './contact.js';
8
+ export * from './face.js';
9
+ export * from './licensePlate.js';
10
+ export * from './motion.js';
11
+ export * from './object.js';
12
+ // Controls
13
+ export * from './light.js';
14
+ export * from './ptz.js';
15
+ export * from './siren.js';
16
+ // Triggers
17
+ export * from './doorbell.js';
18
+ // Info
19
+ export * from './battery.js';
@@ -0,0 +1,116 @@
1
+ import { Sensor } from './base.js';
2
+ import { SensorCategory, SensorType } from './types.js';
3
+ /**
4
+ * License plate sensor property keys
5
+ */
6
+ export var LicensePlateProperty;
7
+ (function (LicensePlateProperty) {
8
+ LicensePlateProperty["Detected"] = "detected";
9
+ LicensePlateProperty["Plates"] = "plates";
10
+ })(LicensePlateProperty || (LicensePlateProperty = {}));
11
+ /**
12
+ * License Plate Sensor (Specialized)
13
+ *
14
+ * Detects and reads license plates in camera frames.
15
+ * Can optionally receive vehicle regions from ObjectSensor for focused detection.
16
+ */
17
+ export class LicensePlateSensor extends Sensor {
18
+ type = SensorType.LicensePlate;
19
+ category = SensorCategory.Sensor;
20
+ name;
21
+ constructor(name = 'License Plate Sensor') {
22
+ super();
23
+ this.name = name;
24
+ // Initialize defaults
25
+ this.props.detected = false;
26
+ this.props.plates = [];
27
+ }
28
+ /** Whether license plates are currently detected */
29
+ get detected() {
30
+ return this.rawProps.detected;
31
+ }
32
+ /** Set license plate detected state */
33
+ set detected(value) {
34
+ this.props.detected = value;
35
+ }
36
+ /** Current license plate detections */
37
+ get plates() {
38
+ return this.rawProps.plates;
39
+ }
40
+ /** Set license plate detections */
41
+ set plates(value) {
42
+ this.props.plates = value;
43
+ }
44
+ /**
45
+ * Update license plate detection state
46
+ *
47
+ * @param detected - Whether license plates are detected
48
+ *
49
+ * @param plates - Array of license plate detections
50
+ */
51
+ setPlates(detected, plates = []) {
52
+ this.props.detected = detected;
53
+ this.props.plates = plates;
54
+ }
55
+ /** Clear license plate detection state */
56
+ clearPlates() {
57
+ this.props.detected = false;
58
+ this.props.plates = [];
59
+ }
60
+ /**
61
+ * Get plate texts
62
+ *
63
+ * @returns Array of detected plate texts
64
+ */
65
+ getPlateTexts() {
66
+ return this.plates.map((p) => p.plateText);
67
+ }
68
+ /**
69
+ * Check if specific plate is detected
70
+ *
71
+ * @param plateText - Plate text to check
72
+ *
73
+ * @returns True if plate is detected, false otherwise
74
+ */
75
+ hasPlate(plateText) {
76
+ return this.plates.some((p) => p.plateText === plateText);
77
+ }
78
+ }
79
+ /**
80
+ * License Plate Detector Sensor (Active Detection)
81
+ *
82
+ * Use this class for frame-based license plate detection (OpenALPR, etc.)
83
+ * The `inputProperties` getter specifies the required input format.
84
+ *
85
+ * Receives cropped vehicle regions from ObjectDetectorSensor for efficient processing.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * class OpenALPRDetector extends LicensePlateDetectorSensor {
90
+ * get inputProperties(): VideoInputProperties {
91
+ * return { width: 320, height: 160, format: 'rgb' };
92
+ * }
93
+ *
94
+ * async detectLicensePlates(frame: VideoFrameData, vehicleRegions?: Detection[]): Promise<LicensePlateResult> {
95
+ * const plates = await this.alpr.recognize(frame.data);
96
+ * return {
97
+ * detected: plates.length > 0,
98
+ * plates: plates.map(p => ({
99
+ * label: 'license_plate',
100
+ * confidence: p.confidence,
101
+ * box: p.box,
102
+ * plateText: p.text,
103
+ * plateConfidence: p.textConfidence,
104
+ * })),
105
+ * };
106
+ * }
107
+ * }
108
+ * ```
109
+ */
110
+ export class LicensePlateDetectorSensor extends LicensePlateSensor {
111
+ /**
112
+ * Indicates this sensor requires video frames for detection.
113
+ * Used by the backend to determine streaming requirements.
114
+ */
115
+ _requiresFrames = true;
116
+ }
@@ -0,0 +1,66 @@
1
+ import { Sensor } from './base.js';
2
+ import { SensorCategory, SensorType } from './types.js';
3
+ /**
4
+ * Light Capability enum
5
+ * Describes what Light features this sensor supports
6
+ * Note: "on" property is always available (standard)
7
+ */
8
+ export var LightCapability;
9
+ (function (LightCapability) {
10
+ /** Supports brightness control */
11
+ LightCapability["Brightness"] = "brightness";
12
+ })(LightCapability || (LightCapability = {}));
13
+ /**
14
+ * Light control property keys
15
+ */
16
+ export var LightProperty;
17
+ (function (LightProperty) {
18
+ LightProperty["On"] = "on";
19
+ LightProperty["Brightness"] = "brightness";
20
+ })(LightProperty || (LightProperty = {}));
21
+ /**
22
+ * Light Control
23
+ *
24
+ * Bidirectional control for camera spotlight/floodlight.
25
+ * Properties can be set directly: `light.on = true`
26
+ */
27
+ export class LightControl extends Sensor {
28
+ type = SensorType.Light;
29
+ category = SensorCategory.Control;
30
+ name;
31
+ constructor(name = 'Light') {
32
+ super();
33
+ this.name = name;
34
+ // Initialize defaults
35
+ this.props.on = false;
36
+ this.props.brightness = 100;
37
+ }
38
+ /** Whether light is on */
39
+ get on() {
40
+ return this.rawProps.on;
41
+ }
42
+ /** Turn light on/off */
43
+ set on(value) {
44
+ this.props.on = value;
45
+ }
46
+ /** Brightness level (0-100) */
47
+ get brightness() {
48
+ return this.rawProps.brightness;
49
+ }
50
+ /** Set brightness level (0-100) */
51
+ set brightness(value) {
52
+ this.props.brightness = Math.max(0, Math.min(100, value));
53
+ }
54
+ /** Turn light on */
55
+ turnOn() {
56
+ this.props.on = true;
57
+ }
58
+ /** Turn light off */
59
+ turnOff() {
60
+ this.props.on = false;
61
+ }
62
+ /** Toggle light state */
63
+ toggle() {
64
+ this.props.on = !this.on;
65
+ }
66
+ }
@@ -0,0 +1,103 @@
1
+ import { Sensor } from './base.js';
2
+ import { SensorCategory, SensorType } from './types.js';
3
+ /**
4
+ * Motion sensor property keys
5
+ */
6
+ export var MotionProperty;
7
+ (function (MotionProperty) {
8
+ MotionProperty["Detected"] = "detected";
9
+ MotionProperty["Detections"] = "detections";
10
+ })(MotionProperty || (MotionProperty = {}));
11
+ /**
12
+ * Motion Sensor
13
+ *
14
+ * Base class for external motion detection (Ring, ONVIF events, SMTP, etc.)
15
+ * Properties can be set directly: `sensor.detected = true`
16
+ *
17
+ * For frame-based motion detection, use `MotionDetectorSensor` instead.
18
+ */
19
+ export class MotionSensor extends Sensor {
20
+ type = SensorType.Motion;
21
+ category = SensorCategory.Sensor;
22
+ name;
23
+ /**
24
+ * External motion sensors don't require video frames.
25
+ * They receive motion events from external sources (SMTP, ONVIF, Ring API, etc.)
26
+ */
27
+ _requiresFrames = false;
28
+ constructor(name = 'Motion Sensor') {
29
+ super();
30
+ this.name = name;
31
+ // Initialize defaults
32
+ this.props.detected = false;
33
+ this.props.detections = [];
34
+ }
35
+ /** Whether motion is currently detected */
36
+ get detected() {
37
+ return this.rawProps.detected;
38
+ }
39
+ /** Set motion detected state */
40
+ set detected(value) {
41
+ this.props.detected = value;
42
+ }
43
+ /** Current motion detections */
44
+ get detections() {
45
+ return this.rawProps.detections;
46
+ }
47
+ /** Set motion detections */
48
+ set detections(value) {
49
+ this.props.detections = value;
50
+ }
51
+ /**
52
+ * Update both detected state and detections at once
53
+ *
54
+ * @param detected - Whether motion is detected
55
+ *
56
+ * @param detections - Array of motion detections
57
+ */
58
+ setMotion(detected, detections = []) {
59
+ this.props.detected = detected;
60
+ this.props.detections = detections;
61
+ }
62
+ /** Clear motion state */
63
+ clearMotion() {
64
+ this.props.detected = false;
65
+ this.props.detections = [];
66
+ }
67
+ }
68
+ /**
69
+ * Motion Detector Sensor (Active Detection)
70
+ *
71
+ * Use this class for frame-based motion detection (rust-motion, OpenCV, etc.)
72
+ * The `inputProperties` getter specifies the required input format.
73
+ *
74
+ * For external motion events (Ring, ONVIF, SMTP), use the base `MotionSensor` class instead.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * class RustMotionDetector extends MotionDetectorSensor {
79
+ * get inputProperties(): VideoInputProperties {
80
+ * return { width: 320, height: 240, format: 'gray' };
81
+ * }
82
+ *
83
+ * async detectMotion(frame: VideoFrameData): Promise<MotionResult> {
84
+ * const result = await this.rustDetector.process(frame.data);
85
+ * return {
86
+ * detected: result.motionDetected,
87
+ * detections: result.regions.map(r => ({
88
+ * label: 'motion',
89
+ * confidence: r.intensity,
90
+ * box: r.boundingBox,
91
+ * })),
92
+ * };
93
+ * }
94
+ * }
95
+ * ```
96
+ */
97
+ export class MotionDetectorSensor extends MotionSensor {
98
+ /**
99
+ * Indicates this sensor requires video frames for detection.
100
+ * Used by the backend to determine streaming requirements.
101
+ */
102
+ _requiresFrames = true;
103
+ }
@@ -0,0 +1,137 @@
1
+ import { Sensor } from './base.js';
2
+ import { SensorCategory, SensorType } from './types.js';
3
+ /**
4
+ * Object sensor property keys
5
+ */
6
+ export var ObjectProperty;
7
+ (function (ObjectProperty) {
8
+ ObjectProperty["Detected"] = "detected";
9
+ ObjectProperty["Detections"] = "detections";
10
+ ObjectProperty["Labels"] = "labels";
11
+ })(ObjectProperty || (ObjectProperty = {}));
12
+ /**
13
+ * Object Sensor
14
+ *
15
+ * Base class for external object detection (Ring, ONVIF events, Eufy, etc.)
16
+ * Properties can be set directly: `sensor.detected = true`
17
+ *
18
+ * For frame-based object detection, use `ObjectDetectorSensor` instead.
19
+ */
20
+ export class ObjectSensor extends Sensor {
21
+ type = SensorType.Object;
22
+ category = SensorCategory.Sensor;
23
+ name;
24
+ /**
25
+ * External object sensors don't require video frames.
26
+ * They receive detection events from external sources (APIs, ONVIF, etc.)
27
+ */
28
+ _requiresFrames = false;
29
+ constructor(name = 'Object Sensor') {
30
+ super();
31
+ this.name = name;
32
+ // Initialize defaults
33
+ this.props.detected = false;
34
+ this.props.detections = [];
35
+ this.props.labels = [];
36
+ }
37
+ /** Whether objects are currently detected */
38
+ get detected() {
39
+ return this.rawProps.detected;
40
+ }
41
+ /** Set object detected state */
42
+ set detected(value) {
43
+ this.props.detected = value;
44
+ }
45
+ /** Current object detections */
46
+ get detections() {
47
+ return this.rawProps.detections;
48
+ }
49
+ /** Set object detections */
50
+ set detections(value) {
51
+ this.props.detections = value;
52
+ }
53
+ /** Labels currently being detected */
54
+ get labels() {
55
+ return this.rawProps.labels;
56
+ }
57
+ /** Set detected labels */
58
+ set labels(value) {
59
+ this.props.labels = value;
60
+ }
61
+ /**
62
+ * Update object detection state
63
+ *
64
+ * @param detected - Whether objects are detected
65
+ *
66
+ * @param detections - Array of object detections
67
+ */
68
+ setObjects(detected, detections = []) {
69
+ this.props.detected = detected;
70
+ this.props.detections = detections;
71
+ // Extract unique labels from detections
72
+ const labelSet = new Set(detections.map((d) => d.label));
73
+ this.props.labels = Array.from(labelSet);
74
+ }
75
+ /** Clear object detection state */
76
+ clearObjects() {
77
+ this.props.detected = false;
78
+ this.props.detections = [];
79
+ this.props.labels = [];
80
+ }
81
+ /**
82
+ * Get detections filtered by label
83
+ *
84
+ * @param label - The label to filter detections by
85
+ *
86
+ * @returns Array of detections matching the label
87
+ */
88
+ getDetectionsByLabel(label) {
89
+ return this.detections.filter((d) => d.label === label);
90
+ }
91
+ /**
92
+ * Check if specific label is detected
93
+ *
94
+ * @param label - Label to check
95
+ *
96
+ * @returns True if label is detected, false otherwise
97
+ */
98
+ hasLabel(label) {
99
+ return this.labels.includes(label);
100
+ }
101
+ }
102
+ /**
103
+ * Object Detector Sensor (Active Detection)
104
+ *
105
+ * Use this class for frame-based object detection (TensorFlow, YOLO, etc.)
106
+ * The `inputProperties` getter specifies the required input format.
107
+ *
108
+ * For external object events, use the base `ObjectSensor` class instead.
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * class TensorFlowObjectDetector extends ObjectDetectorSensor {
113
+ * get inputProperties(): VideoInputProperties {
114
+ * return { width: 640, height: 640, format: 'rgb' };
115
+ * }
116
+ *
117
+ * async detectObjects(frame: VideoFrameData): Promise<ObjectResult> {
118
+ * const predictions = await this.model.detect(frame.data);
119
+ * return {
120
+ * detected: predictions.length > 0,
121
+ * detections: predictions.map(p => ({
122
+ * label: p.class,
123
+ * confidence: p.score,
124
+ * box: p.bbox,
125
+ * })),
126
+ * };
127
+ * }
128
+ * }
129
+ * ```
130
+ */
131
+ export class ObjectDetectorSensor extends ObjectSensor {
132
+ /**
133
+ * Indicates this sensor requires video frames for detection.
134
+ * Used by the backend to determine streaming requirements.
135
+ */
136
+ _requiresFrames = true;
137
+ }