In Social Distancing Detector
we present a tool to monitor people's compliance to social distancing in crowded places in real-time. Our approach is based on YOLOv3 neural network to detect pedestrian in a video stream and on homography to get the bird view of a user-selected ROI. From people's position in the bird view we measure the pairwise distance and then we show the results.
For more information, read the report located in the repo root.
To get a local copy up and running follow these simple steps.
- Clone the repo
git clone https://github.com/LorenzoAgnolucci/SocialDistancingDetector.git
-
Download the network weights from the link in
yolo-coco/yolov3_weights.txt
and copy them in theyolo-coco
folder -
If you want to run the code on a GPU (strongly recommended but not necessary), follow this tutorial to compile OpenCV accordingly
-
The project provides a
requirements.txt
file that can be used to install all the dependencies (except for OpenCV if you compiled it) in order to avoid dependency/reproducibility problems. For example in your virtual environment run
pip install -r requirements.txt
-
If you want to calibrate your camera print a chessboard, take at least 20 photos from different angles and distances and copy them in a folder. Run
camera_calibration.py
modifying the paths and the chessboard parameters as needed -
If needed change the
frame_to_skip
parameter inVideoGet.py
to skip an arbitrary number of frames to reduce the latency -
Run
social_distance_detector.py
and choose the input video stream (optionally adding the calibration matrices path) between the available ones:- Computer webcam
- IP webcam
- Local video (some examples are in
/video
) - Link to stream (some examples are in
webcam_stream.txt
)
Image and Video Analysis © Course held by Professor Pietro Pala - Computer Engineering Master Degree @University of Florence