This project is a social distancing detector implemented in Python with OpenCV and Tensorflow. The result that can be obtained is the following :
If you are working under a Linux distribution or a MacOS, use this tutorial from Adrian Rosebrock to install this library.
All the other requirements can be installed via the command :
pip install -r requirements.txt
In my project I used the faster_rcnn_inception_v2_coco model. I could not upload it to github because it is to heavy. You can download this model and several others from the Tensorflow detection model zoo. Just download all the models you want to try out, put them in the models folder and unzip them. For example :
tar -xvzf faster_rcnn_inception_v2_coco_2018_01_28.tar.gz
Run
python calibrate_with_mouse.py
You will be asked as input the name of the video and the size of the frame you want to work with. The default values are PETS2009.avi and 800 pixels.
Note : It is important to start with the top right corner, than the bottom right, then bottom left, than end by top left corner !
You can add any video to the video folder and work with that.
Run
python social_distanciation_video_detection.py
You will be asked as inputs :
- The tensorflow model you want to use (default value faster_rcnn_inception_v2_coco_2018_01_28).
- The name of the video (default value PETS2009.avi).
- The distance (in pixels between 2 persons).
Both video outputs (normal frame and bird eye view) will be stored in the outputs file.