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 = ...