This project implements a system for tracking people in video streams, detecting line crossings, and recognizing attributes such as gender, bag presence, and hat presence. It utilizes YOLO for object detection and a custom Multi-Task CNN for attribute recognition (PAR).
The tracker.py script processes video files to:
- Track People: Uses YOLOv8 (or YOLOv8-seg) and BoT-SORT for robust person tracking.
- Detect Line Crossings: Counts people crossing defined lines in specific directions.
- Recognize Attributes: Classifies detected people for:
- Gender: Male / Female
- Bag: Yes / No
- Hat: Yes / No
The project relies on the following key libraries:
- Ultralytics YOLO: For object detection and tracking.
- PyTorch: Deep learning framework for the PAR model.
- OpenCV (cv2): Video processing and drawing visualizations.
- NumPy: Numerical operations.
- Shapely: Geometric operations for polygon containment and line intersections.
- Pillow (PIL): Image manipulation.
To run the tracker on a video file:
python tracker.py --input <path_to_video> --output <path_to_output> --config <path_to_config>| Argument | Default | Description |
|---|---|---|
--input |
../video.mp4 |
Path to the input video file. |
--output |
./output/output.mp4 |
Path where the processed video will be saved. |
--config |
./config/camera.json |
Path to the camera configuration file (defines lines and zones). |
python tracker.py --input data/my_video.mp4 --output results/tracked_video.mp4Alternatively, you can run the script with the default arguments:
python tracker.py