Face recognition
Assuming that you have successfully installed OpenCV, we can test this out by simply importing cv
with Python. Open up a Terminal and type python
to start the shell and then, type the following command:
import cv2
If everything goes OK and there are no errors on the screen, you should be fine. Else, go back and reinstall OpenCV as described previously. Now, let's break down the actual code, which you can find and download from the following link:
https://github.com/shantnu/FaceDetect/
In the face_detect.py
script, the abba.png
image, and the haarcascade_frontalface_default.xml
are the following. When executing the file, you have to pass these two arguments:
# Get user supplied values
imagePath = sys.argv[1]
cascPath = sys.argv[2]
As a result, you first pass in the image and then, cascade names. In the following example, we will use the Abba image as the source input image and the default cascade for detecting almost all the faces provided by OpenCV. With the following code,...