Skip to content

Video Analytics

Manage camera streams and run real-time analytics including face detection, person tracking, and people counting. Supports RTSP cameras, USB devices, and video files.

POST /api/v1/video/cameras
FieldTypeRequiredDescription
camera_idstringYesUnique identifier for this camera
sourcestringYesRTSP URL, file path, or device index

Source examples:

  • RTSP: "rtsp://admin:pass@192.168.1.100:554/stream"
  • USB device: "0" (first webcam), "1" (second webcam)
  • Video file: "/path/to/video.mp4"
Terminal window
curl -X POST http://localhost:8000/api/v1/video/cameras \
-d '{
"camera_id": "lobby-cam-1",
"source": "rtsp://admin:pass@192.168.1.100:554/stream"
}'
{
"camera_id": "lobby-cam-1",
"source": "rtsp://admin:pass@192.168.1.100:554/stream",
"is_running": true,
"fps": 25.0,
"frame_count": 0
}

Returns 409 if a camera with the same camera_id already exists.

DELETE /api/v1/video/cameras/{camera_id}
Terminal window
curl -X DELETE http://localhost:8000/api/v1/video/cameras/lobby-cam-1 \
{
"removed": "lobby-cam-1"
}
GET /api/v1/video/cameras
Terminal window
curl http://localhost:8000/api/v1/video/cameras \
[
{
"camera_id": "lobby-cam-1",
"source": "rtsp://admin:pass@192.168.1.100:554/stream",
"is_running": true,
"fps": 24.8,
"frame_count": 18420
},
{
"camera_id": "entrance-cam",
"source": "rtsp://admin:pass@192.168.1.101:554/stream",
"is_running": true,
"fps": 15.0,
"frame_count": 9210
}
]

Get the latest frame from a camera as a JPEG image.

GET /api/v1/video/cameras/{camera_id}/snapshot
Terminal window
curl http://localhost:8000/api/v1/video/cameras/lobby-cam-1/snapshot \
--output snapshot.jpg

Returns image/jpeg content. Returns 404 if the camera is not found or no frame is available.

FieldTypeDescription
camera_idstringUnique camera identifier
sourcestringCamera source (URL, path, or device index)
is_runningboolWhether the stream is actively capturing
fpsfloatCurrent frames per second
frame_countintTotal frames captured since camera was added

When person detection is enabled, you can define counting lines and zones. As tracked people cross a line or enter/exit a zone, events are emitted:

  • Line crossing — define a virtual line in the frame; count people crossing in each direction
  • Zone counting — define a polygon region; track entries and exits

These events are delivered through the event system. See Events & Webhooks for details.

EventDescription
person_enteredA person entered a defined zone
person_exitedA person exited a defined zone
line_crossedA person crossed a counting line
ParameterTypeDefaultDescription
enabledboolfalseEnable video module
max_fpsfloat30.0Maximum processing FPS
track_facesbooltrueRun face detection on camera frames
buffer_sizeint10Frame buffer size per camera
  • Use descriptive camera_id values (e.g., "lobby-entrance", "parking-lot-a")
  • RTSP streams over TCP are more reliable than UDP in congested networks
  • Set max_fps to match your processing budget; 10-15 FPS is sufficient for most counting use cases
  • Monitor is_running status and re-add cameras that disconnect
  • Use snapshots for debugging camera alignment and coverage