Code Monkey home page Code Monkey logo

faceblurer's Introduction

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

faceblurer's People

Contributors

aliyevorkhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.