Let me put a veil on that face of yours

It is often required to blur out the faces of people in an image. Google Street View does this to protect the identity of the people in an area. Several military applications need this too. While this would seem a daunting task to any beginner, SimpleCV makes everything really… um… simple.

The code to detect a face and blur that area out is as follows:

import SimpleCV
cam = Camera()
haarcascade = HaarCascade("face")
while True:
img = cam.getImage().flipHorizontal().scale(0.5)
faces = img.findHaarFeatures(haarcascade)
if faces:
bb = faces[-1].boundingBox()
img = img.pixelize(10, region=(bb[0], bb[1], bb[2], bb[3]))
img.show()

Face Blur

An Example of Face Blur

Hope you’ll find cool and innovative applications for the awesome algorithm above. Peace.

Advertisements