Skip to content

aliyevorkhan/FaceBlurer

Repository files navigation

Face Blurer

First you need to install requirements

pip3 install -r requirements.txt

If your packages are satisfied

How it works for images

Before running, let's check usage.py out:

  1. Import sys lib for give argument from command line:
import sys
  1. Import cv2:
import cv2
  1. Import face_blurer lib to blur the faces:
import face_blurer
  1. Get given argument:
image_path = sys.argv[1]
  1. Read image from given path:
image = cv2.imread(image_path)
  1. Blur the faces in image:
image = face_blurer.blur_face(image)
  1. Finally write result image to directory and show it on window:
cv2.imwrite("result.jpg", image)

cv2.imshow("Result", image)
cv2.waitKey(0)

Running

NOTE: When running of usage.py you have to give image as parameter. It shown below.

For Linux:

python3 usage.py img.png

For Windows:

python usage.py img.png

How it works for live

Before running, let's check usage_live.py out:

  1. Import libraries as above
  2. Realize default steps for real time caturing
  3. Blur each frame before showing:
frame = face_blurer.blur_face(frame, 3)
  1. Get number of faces for each frame:
num_of_faces_frame = face_blurer.num_of_faces(frame)
  1. Show number of faces for each frame:
frame = cv2.putText(frame, str(num_of_faces_frame), 
                    (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, (255, 0, 0), 3)
  1. At final step, show result frame by frame:
cv2.imshow('frame', frame)

About methods

blur_face() method parameters:

blur_face(image_path, level=1)
  1. first parameter is image
  2. level of bluring, default is '1' (0 = low, 1 = mid, 2 = high)

num_of_faces method parameters:

This method return number of faces in given image.

num_of_faces(image)
  • it just get a parameter, image

Outputs

For usage.py

Result Image 1

Result Image 2

For usage_live.py

Result Live

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages