A computer vision solution for real-time pedestrian counting using advanced object detection and tracking algorithms. This system accurately monitors foot traffic by detecting people entering and exiting designated areas in video streams.
The Footfall Counter leverages state-of-the-art object detection (YOLOv5) and multi-object tracking (ByteTrack) to provide accurate pedestrian counting capabilities. The system maintains individual track IDs for each person, enabling sophisticated analytics including re-entry detection and directional flow analysis.
- Real-time Processing: Processes video streams in real-time for immediate footfall analytics
- Accurate Tracking: Maintains unique track IDs for each individual to prevent double counting
- Bidirectional Counting: Distinguishes between people entering and exiting designated areas
- Re-entry Detection: Identifies when the same individual re-enters the monitored zone
- Configurable Zones: Customizable detection areas (highlighted in green) for flexible deployment
- Robust Performance: Handles occlusions, varying lighting conditions, and crowded scenarios
- Python 3.x - Core programming language
- YOLOv5 - Object detection framework for person detection
- ByteTrack - Multi-object tracking algorithm for maintaining object identities
- OpenCV - Computer vision library for video processing
- NumPy - Numerical computing for efficient array operations
Ensure you have Python 3.x installed on your system along with pip package manager.
-
Clone the repository
git clone https://github.com/R-Saad007/Footfall-Counter.git cd Footfall-Counter -
Set up ByteTrack
git clone https://github.com/ifzhang/ByteTrack.git cd ByteTrack pip install -r requirements.txt python3 setup.py develop pip install cython_bbox cd ..
-
Set up YOLOv5
git clone https://github.com/ultralytics/yolov5.git cd yolov5 pip install -r requirements.txt cd ..
-
Install additional dependencies
pip install -r requirements.txt
Run the footfall counter on your video file:
python handler.py -vid_path path/to/your/video.mp4-vid_path: Path to the input video file (required)
The system will display the processed video with:
- Bounding boxes around detected persons
- Unique track IDs for each individual
- Real-time counters for people entering and exiting
- Visual indication of the counting zone (green area)
Note: Add screenshots of your application in action showing the detection boxes, track IDs, and counting interface
The footfall counting system operates through a sophisticated pipeline:
Detection Phase: YOLOv5 identifies all persons in each video frame with high accuracy, providing bounding box coordinates and confidence scores.
Tracking Phase: ByteTrack associates detections across frames, maintaining consistent track IDs even through occlusions and temporary disappearances.
Counting Logic: The system maintains two key dictionaries to track object states:
- Entry/exit status monitoring for each tracked individual
- Historical data to handle re-entries and prevent duplicate counting
Zone Analysis: Objects crossing the designated green counting zone trigger increment operations based on their movement direction and previous state.
The counting mechanism uses a state-based approach where each tracked object maintains:
- Current position relative to the counting zone
- Entry/exit history
- Movement trajectory for directional analysis
- Efficient memory management through dictionary-based state tracking
- Optimized video processing pipeline for real-time performance
- Smart re-identification logic to handle temporary occlusions
- Retail Analytics: Monitor customer flow in stores and shopping centers
- Event Management: Track attendance and crowd density at venues
- Security Applications: Enhance surveillance systems with automated counting
- Urban Planning: Analyze pedestrian traffic patterns in public spaces
- Building Management: Monitor occupancy levels in commercial buildings
- Integration with cloud analytics platforms
- Support for multiple counting zones in a single video
- Heat map generation for traffic pattern visualization
- API endpoints for real-time data access
- Mobile app integration for remote monitoring
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests to help improve this project.
This project is open source. Please check the repository for specific license terms.
- ByteTrack Team for the robust multi-object tracking framework
- Ultralytics for the YOLOv5 object detection model
- OpenCV Community for comprehensive computer vision tools
This project demonstrates practical application of modern computer vision techniques for real-world analytics challenges.