Back to all engineering articles
Jul 10, 20268 min readAI & Computer Vision

Realtime AI Camera Stream Processing & Attendance Sync in Odoo using FastAPI and RTSP

Deep dive into the architecture of xcamera: processing RTSP camera video streams, detecting faces with OpenCV, and dispatching instant attendance webhooks into Odoo ERP.

#xcamera#FastAPI#OpenCV#Go2RTC#Edge AI#Odoo

High-Throughput Edge AI Camera Architecture

Connecting IP cameras directly to Odoo is inefficient due to high video decoding overhead. In `xcamera`, we built an asynchronous edge microservice using **FastAPI**, **Go2RTC**, and **OpenCV**:

  • **Camera Ingestion**: Go2RTC Stream Broker ingests RTSP feeds with low latency.
  • **AI Worker**: OpenCV and Face Detection engine processes frames asynchronously.
  • **Event Queue**: FastAPI event queue delivers match events to Odoo HR Attendance APIs with retry policies.

1. Zero-Latency Video Ingestion with Go2RTC

Go2RTC ingests RTSP/H.264 streams from multiple surveillance cameras without CPU transcoding, distributing low-latency frames to our AI worker threads.

2. Face Recognition & Debouncing

To avoid spamming the ERP with dozens of check-in events when a person walks past the camera, we apply a 15-minute sliding-window cooldown per employee ID:

class AttendanceDebouncer:
    def __init__(self, cooldown_minutes: int = 15):
        self.cooldown = timedelta(minutes=cooldown_minutes)
        self.last_seen: Dict[int, datetime] = {}

def should_record(self, employee_id: int) -> bool: now = datetime.now() last = self.last_seen.get(employee_id) if not last or (now - last) > self.cooldown: self.last_seen[employee_id] = now return True return False ```

3. Asynchronous Webhook Dispatching to Odoo

When a valid match occurs, `xcamera` sends a JSON payload with the employee's ID, timestamp, camera location, confidence score, and event snapshot URL to the Odoo endpoint.

Võ Nghĩa Kỳ

Võ Nghĩa Kỳ

Senior Full-Stack & Odoo 18/19 Developer

Discuss Project Architecture