Face detection with Python
Here is how you can implement Face detection with Python and OpenCV in less than 25 lines of code: Face detection with Python and OpenCV Install OpenCV. Now download the code from repo Now Let's break down the code # Get user supplied values imagePath = sys . argv [ 1 ] cascPath = sys . argv [ 2 ] The above lines takes image and cascade as input. The default cascade will help in detecting image with OpenCV. # Create the haar cascade faceCascade = cv2 . CascadeClassifier ( cascPath ) Now we create a cascade, this loads the face cascade into memory for its use. Cascade is just an XML which contains data to detect faces. # Read the image image = cv2 . imread ( imagePath ) gray = cv2 . cvtColor ( image , cv2 . COLOR_BGR2GRAY ) Here we read the image and convert it into Grayscale. A lot of operations in OpenCV are done in GrayScale. # Detect faces in th...
Comments
Post a Comment