This project is to detect and track person on a video stream and count those going through a defined line.
- Python 3.5 or higher
- OpenCV
- Numpy
- Numba
- imutils
- filterpy
- Scipy (or sklearn version below 0.23.0)
pip install -r requirements.txt
It uses:
-
YOLOv3 to detect objects on each of the video frames. - 用自己的数据训练 YOLOv3 模型
-
SORT to track those objects over different frames.
Once the objects are detected and tracked over different frames a simple mathematical calculation is applied to count the intersections between the vehicles previous and current frame positions with a defined line.
- Download the code to your computer.
- Download [yolov3.weights] and place it in
yolov3_sort/yolo-obj/
- Run the yolov3 counter:
$ python3 main.py --input input/test.mp4 --output output/test.avi --yolo yolo-obj
@article{yolov3,
title={YOLOv3: An Incremental Improvement},
author={Redmon, Joseph and Farhadi, Ali},
journal = {arXiv},
year={2018}
}
@inproceedings{Bewley2016_sort,
author={Bewley, Alex and Ge, Zongyuan and Ott, Lionel and Ramos, Fabio and Upcroft, Ben},
booktitle={2016 IEEE International Conference on Image Processing (ICIP)},
title={Simple online and realtime tracking},
year={2016},
pages={3464-3468},
keywords={Benchmark testing;Complexity theory;Detectors;Kalman filters;Target tracking;Visualization;Computer Vision;Data Association;Detection;Multiple Object Tracking},
doi={10.1109/ICIP.2016.7533003}
}
This implementation was fully taken from this repository.
This repository simplifies the deployment of the above model by:
- Fixing some bugs when there is no detection in a frame and
- Making deployment cross-compatible with sklearn and scipy's implementation of
linear_assignment