Camera Manager Service
Role: The Producer (I/O Bound)
Source: services/camera-manager
Responsibilities
The Camera Manager is responsible for interfacing with the physical world. It maintains persistent application-level connections to RTSP IP cameras.
1. Hardware-Accelerated Decoding
Using the h264_cuvid codec, the service offloads the heavy lifting of video decompression to the GPU's NVDEC engine.
Benefit: This leaves the GPU's CUDA Cores free for AI Inference.
2. Frame Pre-processing
Before sending frames to the pipeline, the manager:
- Resizes images to the model's native resolution (e.g., 640x640) using
cv2.cuda.resize. - Normalizes pixel data if required.
- Encodes the frame to JPEG (Quality 85) to minimize Redis bandwidth usage.
3. Robust Connectivity
Cameras are unreliable IoT devices. The service implements a "Self-Healing" loop:
- Pings the stream every few seconds.
- Automatically destroys and recreates the OpenCV capture object if the stream freezes.
- Logs connectivity metrics to Prometheus.