How to Blur Faces in Images using OpenCV in Python? Last Updated : 03 Jan, 2023 Comments Improve Suggest changes Like Article Like Report Prerequisite: OpenCV OpenCV is a huge open-source library for computer vision, machine learning, and image processing. It can process images and videos to identify objects, faces, or even the handwriting of a human. When it is integrated with various libraries, such as Numpy which is a highly optimized library for numerical operations, then the number of weapons increases in your Arsenal i.e whatever operations one can do in Numpy can be combined with OpenCV. This article discusses how a face in an image can be blurred using OpenCV. Requirements: Apart from OpenCV module, to obtain this functionality we also need Haar Cascade frontal-face classifier needs to be downloaded. It is available as XML file and is used for detecting faces in an image Approach Import moduleReading an image using OpenCVPlotting itDetect faceDraw a rectangle on the detected faceBlur the rectangleDisplay output Below is the implementation. Input image: Original: my_img.jpg Python3 # Importing libraries import numpy as np import cv2 import matplotlib.pyplot as plt # A function for plotting the images def plotImages(img): plt.imshow(img, cmap="gray") plt.axis('off') plt.style.use('seaborn') plt.show() # Reading an image using OpenCV # OpenCV reads images by default in BGR format image = cv2.imread('my_img.jpg') # Converting BGR image into a RGB image image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # plotting the original image plotImages(image) face_detect = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml') face_data = face_detect.detectMultiScale(image, 1.3, 5) # Draw rectangle around the faces which is our region of interest (ROI) for (x, y, w, h) in face_data: cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2) roi = image[y:y+h, x:x+w] # applying a gaussian blur over this new rectangle area roi = cv2.GaussianBlur(roi, (23, 23), 30) # impose this blurred image on original image to get final image image[y:y+roi.shape[0], x:x+roi.shape[1]] = roi # Display the output plotImages(image) Output: Blurred image Comment More infoAdvertise with us Next Article How to Blur Faces in Images using OpenCV in Python? S saurabh48782 Follow Improve Article Tags : Python OpenCV Python-OpenCV Practice Tags : python Similar Reads Faces Blur in Videos using OpenCV in Python OpenCV is an open-source cross-platform library for various operating systems, including Windows, Linux, and macOS, for computer vision, machine learning, and image processing. With the help of OpenCV, we can easily process images and videos to recognize objects, faces, or even someone's handwriting 3 min read Cropping Faces from Images using OpenCV - Python Opencv is a python library mainly used for image processing and computer vision. In this article first, we detect faces after that we crop the face from the image. Face detection is the branch of image processing that uses to detect faces. We will use a pre-trained Haar Cascade model to detect faces 3 min read Python | Image blurring using OpenCV Image Blurring refers to making the image less clear or distinct. It is done with the help of various low pass filter kernels. Advantages of blurring: It helps in Noise removal. As noise is considered as high pass signal so by the application of low pass filter kernel we restrict noise. It helps in 2 min read Add image to a live camera feed using OpenCV-Python In this article, we are going to learn how to insert an image in your live camera feed using OpenCV in Python. Stepwise ImplementationStep 1: Importing the libraries CV reads and stores all the images as a NumPy array. We need the NumPy library to manipulate the image and as expected we need the cv2 4 min read Erosion and Dilation of images using OpenCV in python Morphological operations are a set of operations that process images based on shapes. They apply a structuring element to an input image and generate an output image. The most basic morphological operations are two: Erosion and Dilation Basics of Erosion: Erodes away the boundaries of the foreground 2 min read Like