The goal of this project was to build a lightweight edge AI system that could detect people in real time and send alerts without relying on cloud-based inference. I wanted the entire detection pipeline to run locally on a Raspberry Pi so that it could respond quickly, reduce network usage, and continue working even with limited internet connectivity.
The application starts by capturing frames from a USB camera using OpenCV and the V4L2 backend. Each frame is resized and prepared for inference before being passed to a quantized MobileNet SSD model running with Google’s LiteRT runtime. Using a quantized model keeps inference efficient enough to run on Raspberry Pi hardware while maintaining reasonable detection accuracy.
After inference, the model outputs multiple candidate detections. Since object detection models often generate overlapping bounding boxes for the same object, I applied Non-Maximum Suppression (NMS) to remove duplicate detections and keep only the highest-confidence result for each person.
To avoid sending blurry or underexposed images, the application briefly waits for the camera’s auto-exposure to stabilize whenever a new person enters the frame. It also clears buffered frames from the camera before capturing the final snapshot, ensuring the notification contains the most recent image instead of an older buffered frame.
The annotated image is encoded directly in memory and sent to Telegram using the Bot API. This avoids unnecessary disk writes and reduces I/O overhead on the Raspberry Pi.
To make the system suitable for continuous operation, I implemented retry handling for temporary network failures and deployed the application as a systemd service. This allows the gateway to start automatically after boot and recover from unexpected interruptions without manual intervention.
Where This Project Can Be Used
Although this project was built as a learning exercise in edge AI and computer vision, the same architecture can be applied to a variety of real-world scenarios.
Home and Office Monitoring
The system can monitor entrances, hallways, or restricted areas and send instant notifications whenever a person is detected.
Smart Classrooms
Schools can use the gateway to monitor classroom activity, laboratories, or computer rooms without continuously streaming video to a remote server.
Retail Stores
The project can be adapted to monitor customer movement, detect occupancy, or trigger alerts when someone enters specific areas.
Construction Sites and Warehouses
A local edge device can detect workers entering restricted zones and notify supervisors without requiring cloud processing.
Remote Locations
Because inference runs entirely on the Raspberry Pi, the system is well suited for environments with unreliable or limited internet connectivity. Only alert messages need to be transmitted, significantly reducing bandwidth requirements.
AI and Edge Computing Research
The project also serves as a practical example of deploying lightweight computer vision models on embedded hardware. Developers can extend it by adding custom object detection models, face recognition, multiple cameras, or integration with IoT devices and automation platforms.
What I Learned
Building this project reinforced that deploying an AI model is only part of the solution. Real-world systems also need to account for camera behavior, duplicate detections, network interruptions, and long-running reliability. Addressing these practical challenges made the system far more usable than simply running an object detection model on a live video stream.
This project also provided hands-on experience with edge AI deployment, computer vision optimization, Linux service management, and integrating AI applications with external APIs for real-time notifications.