diff --git a/worker.md b/worker.md index 8d99e51..c7ad37e 100644 --- a/worker.md +++ b/worker.md @@ -55,7 +55,7 @@ This message is crucial for the backend to monitor your worker's health and stat "gpuMemoryUsage": 25.1, "cameraConnections": [ { - "cameraIdentifier": "cam-001", + "subscriptionIdentifier": "display-001;cam-001", "modelId": 101, "modelName": "General Object Detection", "online": true @@ -75,7 +75,7 @@ Sent when the worker detects a relevant object. The `detection` object should be ```json { "type": "imageDetection", - "cameraIdentifier": "cam-001", + "subscriptionIdentifier": "display-001;cam-001", "timestamp": "2025-07-14T12:34:56.789Z", "data": { "detection": { @@ -83,7 +83,8 @@ Sent when the worker detects a relevant object. The `detection` object should be "carBrand": "Honda", "carYear": 2023, "bodyType": "Sedan", - "licensePlateText": "ABCD1234" + "licensePlateText": "ABCD1234", + "licensePlateConfidence": 0.95 }, "modelId": 101, "modelName": "US-LPR-and-Vehicle-ID" @@ -167,17 +168,34 @@ Instructs the worker to process a camera's RTSP stream using the configuration f { "type": "subscribe", "payload": { + "subscriptionIdentifier": "display-001;cam-002", "rtspUrl": "rtsp://user:pass@host:port/stream", - "cameraIdentifier": "cam-002", "snapshotUrl": "http://go2rtc/snapshot/1", "snapshotInterval": 5000, "modelUrl": "http://storage/models/us-lpr.mpta", "modelName": "US-LPR-and-Vehicle-ID", - "modelId": 102 + "modelId": 102, + "cropX": 100, + "cropY": 200 } } ``` +> **Note:** +> - `cropX` and `cropY` (optional, integer) specify the initial crop coordinates for the camera stream. These values are configured per display and passed in the subscription payload. If not provided, the worker should process the full frame. +> + +> **Important:** +> If multiple displays are bound to the same camera, your worker must ensure that only **one stream** is opened per camera. When you receive multiple subscriptions for the same camera (with different `subscriptionIdentifier` values), you should: +> +> - Open the RTSP stream **once** for that camera if using RTSP. +> - Capture each snapshot only once per cycle, and reuse it for all display subscriptions sharing that camera. +> - Capture each frame/image only once per cycle. +> - Reuse the same captured image and snapshot for all display subscriptions that share the camera, processing and routing detection results separately for each display as needed. +> +> This avoids unnecessary load and bandwidth usage, and ensures consistent detection results and snapshots across all displays sharing the same camera. + + ### 5.2. Unsubscribe from Camera Instructs the worker to stop processing a camera's stream. @@ -190,7 +208,7 @@ Instructs the worker to stop processing a camera's stream. { "type": "unsubscribe", "payload": { - "cameraIdentifier": "cam-002" + "subscriptionIdentifier": "display-001;cam-002" } } ``` @@ -252,8 +270,8 @@ This section shows a typical sequence of messages between the backend and the wo { "type": "subscribe", "payload": { + "subscriptionIdentifier": "display-001;entry-cam-01", "rtspUrl": "rtsp://192.168.1.100/stream1", - "cameraIdentifier": "entry-cam-01", "modelUrl": "http://storage/models/vehicle-id.mpta", "modelName": "Vehicle Identification", "modelId": 201 @@ -271,7 +289,7 @@ This section shows a typical sequence of messages between the backend and the wo "gpuMemoryUsage": 21.0, "cameraConnections": [ { - "cameraIdentifier": "entry-cam-01", + "subscriptionIdentifier": "display-001;entry-cam-01", "modelId": 201, "modelName": "Vehicle Identification", "online": true @@ -284,14 +302,15 @@ This section shows a typical sequence of messages between the backend and the wo ```json { "type": "imageDetection", - "cameraIdentifier": "entry-cam-01", + "subscriptionIdentifier": "display-001;entry-cam-01", "timestamp": "2025-07-15T10:00:00.000Z", "data": { "detection": { "carBrand": "Honda", "carModel": "CR-V", "bodyType": "SUV", - "licensePlateText": "ABCD1234" + "licensePlateText": "GEMINI-AI", + "licensePlateConfidence": 0.98 }, "modelId": 201, "modelName": "Vehicle Identification" @@ -302,7 +321,7 @@ This section shows a typical sequence of messages between the backend and the wo ```json { "type": "imageDetection", - "cameraIdentifier": "entry-cam-01", + "subscriptionIdentifier": "display-001;entry-cam-01", "timestamp": "2025-07-15T10:00:01.000Z", "data": { "detection": { @@ -310,6 +329,7 @@ This section shows a typical sequence of messages between the backend and the wo "carModel": "Corolla", "bodyType": "Sedan", "licensePlateText": "CMS-1234", + "licensePlateConfidence": 0.97 }, "modelId": 201, "modelName": "Vehicle Identification" @@ -320,7 +340,7 @@ This section shows a typical sequence of messages between the backend and the wo ```json { "type": "imageDetection", - "cameraIdentifier": "entry-cam-01", + "subscriptionIdentifier": "display-001;entry-cam-01", "timestamp": "2025-07-15T10:00:02.000Z", "data": { "detection": { @@ -328,6 +348,7 @@ This section shows a typical sequence of messages between the backend and the wo "carModel": "Focus", "bodyType": "Hatchback", "licensePlateText": "CMS-5678", + "licensePlateConfidence": 0.96 }, "modelId": 201, "modelName": "Vehicle Identification" @@ -340,7 +361,7 @@ This section shows a typical sequence of messages between the backend and the wo { "type": "unsubscribe", "payload": { - "cameraIdentifier": "entry-cam-01" + "subscriptionIdentifier": "display-001;entry-cam-01" } } ```