This project implements a real-time people counting system using a fixed webcam and a deep learning-based object detector. The system detects people entering or exiting a monitored area and tracks overall occupancy using a virtual line-crossing mechanism.
- Live detection using MobileNet SSD (OpenCV DNN)
- Real-time occupancy tracking
- Horizontal or vertical line-crossing configuration
- Jitter-resistant centroid-based tracking
- Frame display with bounding boxes, IDs, and occupancy counters
- Python 3.8+
- OpenCV (4.x)
- NumPy
Install requirements:
pip install opencv-python numpyPlace the MobileNet SSD model files in a models/ folder:
MobileNetSSD_deploy.prototxt.txtMobileNetSSD_deploy.caffemodel
Then run:
python main.py- Live video window showing:
- Detected people with bounding boxes and centroids
- Virtual line (red)
- Entry/exit and current occupancy counts (top left corner)
- Default input resolution is 640x480.
- By default, the virtual line is vertical and centered.
- You can adjust line orientation and position in the script config.
- Multi-person tracking improvements
- Multi-camera handoff support
- Re-identification for lost IDs
Corey Floyd