update worker communication protocol to use subscription identifiers; add crop coordinates for camera streams and clarify handling of multiple subscriptions
Some checks failed
Build Backend Application and Docker Image / build-docker (push) Has been cancelled

This commit is contained in:
Siwat Sirichai 2025-07-13 23:58:01 +07:00
parent 162f29ec21
commit 1ff6108d08

View file

@ -55,7 +55,7 @@ This message is crucial for the backend to monitor your worker's health and stat
"gpuMemoryUsage": 25.1, "gpuMemoryUsage": 25.1,
"cameraConnections": [ "cameraConnections": [
{ {
"cameraIdentifier": "cam-001", "subscriptionIdentifier": "display-001;cam-001",
"modelId": 101, "modelId": 101,
"modelName": "General Object Detection", "modelName": "General Object Detection",
"online": true "online": true
@ -75,7 +75,7 @@ Sent when the worker detects a relevant object. The `detection` object should be
```json ```json
{ {
"type": "imageDetection", "type": "imageDetection",
"cameraIdentifier": "cam-001", "subscriptionIdentifier": "display-001;cam-001",
"timestamp": "2025-07-14T12:34:56.789Z", "timestamp": "2025-07-14T12:34:56.789Z",
"data": { "data": {
"detection": { "detection": {
@ -83,7 +83,8 @@ Sent when the worker detects a relevant object. The `detection` object should be
"carBrand": "Honda", "carBrand": "Honda",
"carYear": 2023, "carYear": 2023,
"bodyType": "Sedan", "bodyType": "Sedan",
"licensePlateText": "ABCD1234" "licensePlateText": "ABCD1234",
"licensePlateConfidence": 0.95
}, },
"modelId": 101, "modelId": 101,
"modelName": "US-LPR-and-Vehicle-ID" "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", "type": "subscribe",
"payload": { "payload": {
"subscriptionIdentifier": "display-001;cam-002",
"rtspUrl": "rtsp://user:pass@host:port/stream", "rtspUrl": "rtsp://user:pass@host:port/stream",
"cameraIdentifier": "cam-002",
"snapshotUrl": "http://go2rtc/snapshot/1", "snapshotUrl": "http://go2rtc/snapshot/1",
"snapshotInterval": 5000, "snapshotInterval": 5000,
"modelUrl": "http://storage/models/us-lpr.mpta", "modelUrl": "http://storage/models/us-lpr.mpta",
"modelName": "US-LPR-and-Vehicle-ID", "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 ### 5.2. Unsubscribe from Camera
Instructs the worker to stop processing a camera's stream. 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", "type": "unsubscribe",
"payload": { "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", "type": "subscribe",
"payload": { "payload": {
"subscriptionIdentifier": "display-001;entry-cam-01",
"rtspUrl": "rtsp://192.168.1.100/stream1", "rtspUrl": "rtsp://192.168.1.100/stream1",
"cameraIdentifier": "entry-cam-01",
"modelUrl": "http://storage/models/vehicle-id.mpta", "modelUrl": "http://storage/models/vehicle-id.mpta",
"modelName": "Vehicle Identification", "modelName": "Vehicle Identification",
"modelId": 201 "modelId": 201
@ -271,7 +289,7 @@ This section shows a typical sequence of messages between the backend and the wo
"gpuMemoryUsage": 21.0, "gpuMemoryUsage": 21.0,
"cameraConnections": [ "cameraConnections": [
{ {
"cameraIdentifier": "entry-cam-01", "subscriptionIdentifier": "display-001;entry-cam-01",
"modelId": 201, "modelId": 201,
"modelName": "Vehicle Identification", "modelName": "Vehicle Identification",
"online": true "online": true
@ -284,14 +302,15 @@ This section shows a typical sequence of messages between the backend and the wo
```json ```json
{ {
"type": "imageDetection", "type": "imageDetection",
"cameraIdentifier": "entry-cam-01", "subscriptionIdentifier": "display-001;entry-cam-01",
"timestamp": "2025-07-15T10:00:00.000Z", "timestamp": "2025-07-15T10:00:00.000Z",
"data": { "data": {
"detection": { "detection": {
"carBrand": "Honda", "carBrand": "Honda",
"carModel": "CR-V", "carModel": "CR-V",
"bodyType": "SUV", "bodyType": "SUV",
"licensePlateText": "ABCD1234" "licensePlateText": "GEMINI-AI",
"licensePlateConfidence": 0.98
}, },
"modelId": 201, "modelId": 201,
"modelName": "Vehicle Identification" "modelName": "Vehicle Identification"
@ -302,7 +321,7 @@ This section shows a typical sequence of messages between the backend and the wo
```json ```json
{ {
"type": "imageDetection", "type": "imageDetection",
"cameraIdentifier": "entry-cam-01", "subscriptionIdentifier": "display-001;entry-cam-01",
"timestamp": "2025-07-15T10:00:01.000Z", "timestamp": "2025-07-15T10:00:01.000Z",
"data": { "data": {
"detection": { "detection": {
@ -310,6 +329,7 @@ This section shows a typical sequence of messages between the backend and the wo
"carModel": "Corolla", "carModel": "Corolla",
"bodyType": "Sedan", "bodyType": "Sedan",
"licensePlateText": "CMS-1234", "licensePlateText": "CMS-1234",
"licensePlateConfidence": 0.97
}, },
"modelId": 201, "modelId": 201,
"modelName": "Vehicle Identification" "modelName": "Vehicle Identification"
@ -320,7 +340,7 @@ This section shows a typical sequence of messages between the backend and the wo
```json ```json
{ {
"type": "imageDetection", "type": "imageDetection",
"cameraIdentifier": "entry-cam-01", "subscriptionIdentifier": "display-001;entry-cam-01",
"timestamp": "2025-07-15T10:00:02.000Z", "timestamp": "2025-07-15T10:00:02.000Z",
"data": { "data": {
"detection": { "detection": {
@ -328,6 +348,7 @@ This section shows a typical sequence of messages between the backend and the wo
"carModel": "Focus", "carModel": "Focus",
"bodyType": "Hatchback", "bodyType": "Hatchback",
"licensePlateText": "CMS-5678", "licensePlateText": "CMS-5678",
"licensePlateConfidence": 0.96
}, },
"modelId": 201, "modelId": 201,
"modelName": "Vehicle Identification" "modelName": "Vehicle Identification"
@ -340,7 +361,7 @@ This section shows a typical sequence of messages between the backend and the wo
{ {
"type": "unsubscribe", "type": "unsubscribe",
"payload": { "payload": {
"cameraIdentifier": "entry-cam-01" "subscriptionIdentifier": "display-001;entry-cam-01"
} }
} }
``` ```