From the course: OpenCV for Python Developers

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Face detection

Face detection

- [Instructor] Now let's take a look at the specific use case of detecting faces in image using the pre-learned Haar classifier. Again, note that detection is not the same thing as recognition. We're only detecting if and where faces are located in an image. For this, we're going to use the pre-included Haar classifier found in the chapter four module five folder. You can see this is the haarcascade_frontalface_default.xml file. Now let's jump into our scripting window, where we'll load out the chapter four, module five Python file. Note that we've already loaded in our image, faces.jpg, in full color, as indicated by the value of one. Next, for the actual classifier, we want to turn this into grayscale. For this we can type gray = cv2.cvt capital C Color, and then pass img,cvt.COLOR, capitalized, underscore, and then BGR2GRAY. This is because our classifier is only working on brightness and not color values. Next…

Contents