2024-03-01 04:57:46.083999+00:00

A client asked me to create a real-time backup system for their CCTV feed. Not only that, they also want the system to detect the names of known persons and cats.

Infrastructure and Tools

  1. Local Processing Unit: I used a Raspberry Pi as the local processing unit to capture video feeds from CCTV cameras. This lightweight and cost-effective solution was ideal for initial video processing at the edge.
  2. Video Segmentation: Using FFmpeg, I configured the Raspberry Pi to segment the video feeds into 1-minute chunks. This ensured manageable file sizes and facilitated real-time processing.
  3. Object Detection and Identification:
    • MobileNet SSD Model: I integrated a pre-trained MobileNet SSD model for object detection, which was capable of identifying various objects, including persons, cars, and cats.
    • Face Recognition: For recognizing known human faces, I used the face_recognition library. This allowed the system to accurately identify specific individuals.
    • Custom Cat Recognition: Implemented custom template matching for identifying specific cats by name.
  4. Asynchronous Messaging: To handle the flow of data between the Raspberry Pi and cloud services, I set up Google Pub/Sub. This allowed for reliable and asynchronous communication, ensuring that data was processed in real-time without bottlenecks.
  5. Serverless Processing: I developed Google Cloud Functions to subscribe to the Pub/Sub topic and process the video segments and metadata. These functions handled the uploading of processed data to Google Cloud Storage, leveraging the scalability of serverless architecture.
  6. Data Processing Pipeline:
    • Apache Beam: I designed a data processing pipeline using Apache Beam, which was deployed on Google Cloud Dataflow. This pipeline read enriched metadata from Pub/Sub, transformed it, and wrote it to BigQuery for storage and analysis.
    • BigQuery: The processed data was stored in BigQuery, allowing for efficient querying and analysis of the video metadata.
  7. Monitoring and Logging:
    • Google Cloud Monitoring: I integrated Google Cloud Monitoring to track custom metrics, such as the number of detected objects by type (humans, cars, cats). Custom metric descriptors were created, and counts were reported at the end of each processing bundle in the Dataflow pipeline.
    • Detailed Logging: Implemented detailed logging within the Dataflow pipeline and Google Cloud Functions to capture significant events and errors, providing real-time insights into system operations.

Development

  1. Configured the Raspberry Pi and implemented video capture and segmentation using FFmpeg.
  2. Integrated and fine-tuned the MobileNet SSD model for object detection and developed the face recognition and cat recognition components.
  3. Set up Google Pub/Sub for asynchronous messaging and developed Cloud Functions for serverless processing.
  4. Built the data processing pipeline using Apache Beam and deployed it on Google Cloud Dataflow.
  5. Implemented logging and monitoring using Google Cloud Monitoring.

Edge RTSP-to-HLS Segment Buffering & Signed Cloud Storage Archival

Segment live RTSP camera feeds with FFmpeg into 4-second fMP4 chunks on local disk and stream completed segments to Google Cloud Storage with automatic lifecycle tiering to Archive storage.


About the Author — Hire Freelance Programmer Aldian Fazrihady

Aldian Fazrihady is a Top-Rated Senior Freelance Programmer, Freelance Full Stack Developer, and AI Application Engineer with 15+ years of production software engineering experience and Google Cloud Professional Cloud Architect & Data Engineer certifications. He specializes in building custom LLM & autonomous AI agents, RAG pipelines, Next.js/React PWAs, Python (Django/FastAPI), Go microservices, and serverless cloud infrastructure on Google Cloud Run and AWS.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD via Polar) | View Live AI Portfolio | Portfolio Directory | Send a Direct Message

Related Engineering Articles

Freelance Programmer Specializations & Category Hubs