feat: add HTTP API for image retrieval from camera; implement endpoint for accessing latest image frames
This commit is contained in:
		
							parent
							
								
									428f7a9671
								
							
						
					
					
						commit
						a1f797f564
					
				
					 1 changed files with 42 additions and 0 deletions
				
			
		
							
								
								
									
										42
									
								
								worker.md
									
										
									
									
									
								
							
							
						
						
									
										42
									
								
								worker.md
									
										
									
									
									
								
							| 
						 | 
					@ -439,3 +439,45 @@ This section shows a typical sequence of messages between the backend and the wo
 | 
				
			||||||
      "cameraConnections": []
 | 
					      "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.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue