This is a really short article, on an unfinished project, if you like face recognition, and want to continue it, DM me wherever.
Do you like surveillance ? Automation of espionnage ? Yeah, me neither, but tech, is tech, and if you don’t do it, others will, and they may care less than you about safety.
The goal of this mini-project is circling faces on an image, and a future part may be applying face recognition to find out who is on the image.
I’m going to use a Jupyter Python notebook, importing the standard scientific python libraries, and cv2 for Computer Vision.
I’ll include code snippets, and, since it’s a very simple task, you may be able to replicate it yourselves.
For this, I’m not going to train my own model (for now), and simply use a Cascade Classifier.
front_cascade = cv2.CascadeClassifier("./cascades/haarcascade_frontalface_alt.xml")
We can import and use images directly with cv2
face_bgr = cv2.imread("./known_faces\\musk.jpg")
Our cascades only like grayscale images, so let’s convert our image
face_gray = cv2.cvtColor(face_bgr, cv2.COLOR_BGR2GRAY)
Now let’s write a script that detects every face, no matter its orientation:
Here we initialize everything we’ll need
detected_faces_coords_tmp = 
And then we create a loop, because sometimes the cascades miss a face, because another one is too obvious. So, we create a blackbox on top of the found faces, to try and see if we didn’t miss one in the background.
For the people that are impressed by circles, I made this.
And here’s the usable data, we could feed into a Neural Network that would detect who is on the picture, or their gender, or edit their features, or whatever pleases your creative ideas !
Okay, that Elon Musk image is generous, of course, it is already almost centered. How about a low-quality, generic group of people ?
See, even low-quality faces are picked up, and transformed into usable images !