From a1f797f564eb2eb60c659052544589622cf09aea Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 15 Jul 2025 00:18:28 +0700 Subject: [PATCH] feat: add HTTP API for image retrieval from camera; implement endpoint for accessing latest image frames --- worker.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/worker.md b/worker.md index 00a13cf..c50bae5 100644 --- a/worker.md +++ b/worker.md @@ -439,3 +439,45 @@ This section shows a typical sequence of messages between the backend and the wo "cameraConnections": [] } ``` +## 7. HTTP API: Image Retrieval + +In addition to the WebSocket protocol, the worker exposes an HTTP endpoint for retrieving the latest image frame from a camera. + +### Endpoint + +``` +GET /camera/{camera_id}/image +``` + +- **`camera_id`**: The full `subscriptionIdentifier` (e.g., `display-001;cam-001`). + +### Response + +- **Success (200):** Returns the latest JPEG image from the camera stream. + - `Content-Type: image/jpeg` + - Binary JPEG data. + +- **Error (404):** If the camera is not found or no frame is available. + - JSON error response. + +- **Error (500):** Internal server error. + +### Example Request + +``` +GET /camera/display-001;cam-001/image +``` + +### Example Response + +- **Headers:** + ``` + Content-Type: image/jpeg + ``` +- **Body:** Binary JPEG image. + +### Notes + +- The endpoint returns the most recent frame available for the specified camera subscription. +- If multiple displays share the same camera, each subscription has its own buffer; the endpoint uses the buffer for the given `camera_id`. +- This API is useful for debugging, monitoring, or integrating with external systems that require direct image access.