Note: This readme is written around the Main_main python file. This Python script utilizes the OpenCV library to implement a simple face tracking system using Haar cascades. Haar cascades are trained classifiers that can be used for object detection. In this case, we are using Haar cascades to detect faces in a video stream. The system draws rectangles around detected faces and provides a basic function when a face is detected.
Before running the script, make sure to install the required libraries. You can install OpenCV using the following:
pip install opencv-pythonThe script uses Haar cascade files for detecting faces. The cascade files can be found in the OpenCV GitHub repository here. The following Haar cascade files are used in this script:
face_default.xml: Cascade file for detecting frontal faces.faceProfile_extended.xml: Cascade file for detecting profile faces.frontalFaceCloser.xml: Additional cascade file for detecting closer frontal faces.
- Ensure that your webcam is connected and functional.
- Run the script.
The script will continuously capture video frames from the specified video capture device (in this case, device index 2). Detected faces will be outlined with rectangles of different colors, and a simple function FaceDetected will be called when a face is detected, printing a message with a random ID.
You can adjust the script's parameters for face detection by modifying the following:
scaleFactor: Parameter specifying how much the image size is reduced at each image scale.minNeighbors: Parameter specifying how many neighbors each candidate rectangle should have to retain it.minSize: Minimum possible object size. Objects below this size will not be detected.
- Python 3.x
- OpenCV
- Press 'q' to exit the video stream.