This program captures each frame from the computer camera and performs cascade classfication on each frame to identify a human face. In this case a human face is the Region Of Interest (ROI). It finds the ROI centre and finds the x and y axis displacement of the object centre from the frame centre.
Object Detection using Haar feature-based cascade classifiers is an effective object detection method. It is a machine learning based approach where a cascade function is trained from a lot of positive and negative images. It is then used to detect objects in other images.
- face_tracker.py - Source code
- haarcascade_frontalface_default.xml - Necessary xml file for object detection
- Create an object from Cascade classifier class for object detection
- Create a videocapture object
- Calculate the frame centre
- Read each frame from the camera feed
- Draws a red dot in the centre of the frame
- Draws a rectangular box around the ROI (Human face)
- Draws a circle around the detected face centre
- Draws a arrow line between the frame centre and the face centre
- Calculates the x and y axis displacement error between the frame and the ROI centre
- Display the modified image
- Checks if esc key is pressed, if not repeat from step 4
- Release the video capture object and destroy all the created windows