/opencv_face_blur

Detect faces in image and apply a blur (for image redaction purposes)

Primary LanguagePython

OpenCV Face Blur

This repo shows a simple face detector and subsequent redaction from an image, using Python 3 and OpenCV (for those who want to remain unseen).

Face blur

Here we make use of two default HAAR cascade from the OpenCV library, one for front-on faces, and another for faces in profile. These cascades provide a good foundation for training your own, supposing you have your own training data. With that in mind, it would be beneficial to train a single HAAR cascade to include a range of faces, and possible positions (note the defaults don't perform well with angled faces, ie from below or above).

An example input, using an image of the band Blur from an article on Mojo

Blur

Another example input, using an image of the band Weezer (no pun this time) from an article on Consequence of Sound

Weezer

The script then detects frontal and profile faces, before applying a gaussian filter to each face, and adding the blur to the original image. This is then saved in the 'results' folder.

Blur blur

Weezer blur