Using mediapipe for face detection and anonymizing faces using basic opencv blur.
FACANO is capable of detecting and anonymizing faces in three different modes i.e., static images, videos, and live webcam feed. It can detect and anonymize multiple faces at once.
Model selection can be set to 1 for images where the subject is 5 meters away from the camera and 0 for images where the subject is 2 meters away. Increasing the minimum detection confidence will lead to more accurate detection but 50% is default.
with mp_face_detection.FaceDetection(model_selection = 0, min_detection_confidence = 0.5) as face_detection:
Given below is an anonymized image that was blurred using a kernel size of 70.
Here is another result with a kernel size of 90 and 120.
The images used here were taken from unsplash.com and the video was taken from pexels.com.
Open the terminal on your mac and type
mkdir FACANO
Then switch to the new directory using
cd FACANO
Now clone the repository on your local machine using
git clone https://github.com/kotiyalanurag/FACANO.git
Now create a virtual environment using (assuming you have python installed on your machine)
python -m venv env
Switch to your new virtual environment using
source env/bin/activate
Now install the requirements for this project using
pip install -r requirements.txt
Use the following script to run this program using a command line interface.
python3 main.py -m [MODE] -n [FILENAME] -e [FILEEXTENSION] -k [KERNELSIZE]
Acceptable modes are image, video, and webcam with .jpg or .mp4 file extensions.
Have fun playing around with the code.