This project is a social distancing detector implemented in Python with OpenCV and Tensorflow. Original project is https://github.com/basileroth75/covid-social-distancing-detection We have modified it to get more user input and play alert sound when people are not maintaining social distancing for certain period of time. The result that can be obtained is the following :
This project is tested under python version 3.6
If you are working under a Linux distribution or a MacOS, use this tutorial from Adrian Rosebrock to install this library. Or following command should work.
pip install opencv-python
pip install tensorflow-gpu==2.1
pip install imutils
pip install PyYaml
pip install soundfile
conda install -c conda-forge python-sounddevice
pip install pyqt5
pip install vidgear
In my project I used the faster_rcnn_inception_v2_coco model. You can also 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 Social_Distance_Check.py
You will be asked as inputs :
- Browse for input Video or WebCam or provide online video link.
- The minimum distance to maintain between 2 persons.
- Time to wait before playing alert sound.
- Time to wait between playing alert sound.
- Output frame size.
- Audio file(.wav format) to play as warning.
- Note: If you did not provide any information. It will run with defaults. *
Video output will be stored in the output file.
- Relation between minimum distance input, frame size and pixel value.
- User input for warning message.
- Detect whether WebCam is connected or not.
- Show output messages in message boxes after completion of job or if some errors occurs.