By ADIL SHAIKH
This project is made meant to provide an easy way to help to detect if social distancing is being followed or not using a depth camera and face detection.
This project is made for enforcing the Social distancing autonomously by providing a simple approach for face detection using OpenCV haar cascade and the intel realsense D415 depth camera with Python as the programming language. The approach is made as simple as possible and consumes requires no extra frameworks except OpenCV and an intel realsense. This logic can be employed in robots that can move around ensuring the same.
It performs face detection using haar cascade classifiers with the classifier XML provided by OpenCV itself. Then we get the depth of the detected faces and calculate the distance between all the detected faces and check if any of them do not satisfy the social distancing criteria. The ones that do not satisfy the criteria are marked in red and the others in blue.
This project uses the following libraries:
REQUIREMENTS:
1. Opencv
2. pyrealsense2
3. numpy4.math
You must have Jupyter notebook installed in your pc.
There are 3 ways to use the given zip file:
1) Directly run the distancing.ipynb file. This is present in the zip folder.
2) Download the distancing.ipynb file as a .py file and combine it with other packages.
3) Train your own cascade classifier and replace the file location and perform custom detection here:
"face_cascade = cv2.CascadeClassifier('/home/adil/python3_dir/social_distancing/haarcascade_frontalface_default.xml')"
NOTE: Do not forget to change the file location of the classifier XML file to your directory before running the script.
EXAMPLE:
1) When only one person gets detected:
2) When social distancing is not followed:
3) When social distancing is followed:
The code works for 'N' number of detections.
Submitted by ADIL SHAIKH (adiljs)
Download packets of source code on Coders Packet
Comments