Here is the link to the folder with some results: Click
input
- folder for input videosmodels
- folder for modelsoutput
- folder for output videospeople_tracker
- folder with codeyolo
- YOLOv3 modeldetector.py
- class for running detectors from TF Zoodetector_yolo.py
- class for running YOLOv3 detectordraw_detections.py
- code to test detectionsmain.py
- track people using Bounding Box Kalman Trackermain_center.py
- track people using Centroid Kalman Trackertools.py
- helper functionstracker.py
- Bounding Box Kalman Trackertracker_center.py
- Centroid Kalman Tracker
Dockerfile
environment.yml
We have a video.mp4
The task is to find all people in each frame, draw bounding box, and assign an ID to each person. The previously detected person should have the same ID when detected again. A new person should get an ID incrementally.
We should save the output in output.mp4
We make an assumption that there will be no instantaneous camera movements and that objects cannot disappear and appear instantaneously.
The approach is the following:
- Generate a list of bounding box detections with some Neural Network
- Solve the data association problem
- Track boxes using Kalman filter. Detections are used as measurements for Kalman filter
Let's use a Neural Network that can detect objects to generate bounding boxes around people.
The selection of a Neural Network for detection profoundly influences the results of tracking. For example, if we use ssd_mobilenet_v2_coco
, the system will work in real-time, but the results are inadequate due to periodic bounding box jitter.
Also, the dataset matters a lot. For example, faster_rcnn_nas
that was trained on the COCO dataset has worse detection accuracy than the faster faster_rcnn_resnet101_kitti
model that was trained on KITTI dataset.
Out of all tested models, YOLOv3 has shown the best result in terms of speed/accuracy. On the system with GPU tracking with YOLOv3 should work in real-time.
The data association problem is approached as an optimization problem. The task is to minimize the weighted sum of bounding boxes. The cost matrix for the centroid tracking approach was constructed using the euclidean distance between centroids. IOU metric was used for the bounding box approach.
The optimization problem is solved with the Hungarian algorithm (also known as the Munkres algorithm).
Given the associated data as measurements, we can track bounding boxes. Two approaches are tested:
The state is represented as coordinates of the bounding box centroid. The centroid of the associated measurement is calculated and passed as a measurement to a Kalman filter.
This approach seems to be more robust to wrong detections.
The state is represented as coordinates of corners of the bounding box. The associated measurement is passed as a measurement to a Kalman filter.
This approach seems to be more robust to occlusions.
- Do proper meta parameter tuning (Kalman, Neural Network, thresholds)
- Retrain models on humans using transfer learning
- Select a better model for Kalman filter
- Combine Kalman filter with more advanced trackers like GOTURN
- Solve the data association problem using additional methods:
- Bipartite Graphs approaches
- Dynamic models integration
- etc
- Do thorough research on new detection and tracking methods
You can run the centroid tracking approach using:
python3 main_center.py ../input/video.mp4
You can run the bounding box tracking approach using:
python3 main.py ../input/video.mp4
Intel Core i5-6200U CPU @ 2.30GHz × 4
- Python
numpy v1.18.2
scipy v1.4.1
- OpenCV (
cv2 v4.2
) - TensorFlow
(tensorflow v1.14.0)
cd
to the TrackingPeople
folder first. Then, download your models:
Unpack downloaded model to:
models
Don't forget to select the downloaded model in main.py
or main_center.py
Download weights Download weights mirror
Save downloaded files to:
people_tracker/yolo/data/darknet_weights/
directory
Don't forget to select the downloaded model in main.py
or main_center.py
There is a Docker environment ready for execution.
Run Docker compose:
sudo xhost +local:root
docker-compose -f environment.yml up --build
Enter the Docker container:
docker exec -it trackingpeople_tracker_1 bash
There you can run some code. Here is an example:
cd people_tracker
python3 main_center.py ../input/video.mp4