Coders Packet

Blur Face using OpenCV Python

By Swarnava Basu

Blur Human Face using OpenCV python. By using this method you can not only blur human faces but also many features like human eyes,nose,ears etc.

Blur Human Face using OpenCV Python. At first import OpenCV and time.

Import all required parts

We need to load face_cascade. Then we load haarcascade. "haarcascade_frontalface_default.xml" contain our feature data. We are using haarcascade for the frontal face. We create the 'video' variable which will record the input from our webcam.

We create a while loop so that we can extract the video. This 'video' variable will click still pictures so what we are doing here is, we are creating a while loop and then creating a slideshow of images. That slideshow of image is called a video. Then inside the While loop we describe the coordinate of our face.

We use here Median blur function from OpenCV to blur our image. In median blur function the first parameter is the image and then we have to define the percentage of te blur(Keep in mind one point that it should be a positive or an Odd number). Here we blur the image 35 %.

Median Blur function


Download Complete Code


No comments yet