Using the OpenCV library to detect faces in a live stream from webcam or in a locally stored video file !
The following program uses the OpenCV library to detect faces in a live stream from webcam or in a video file stored in the local machine. This program detects faces in real time and tracks it. It uses pre-trained XML classifiers for the same. The classifiers used in this program have facial features trained in them. Different classifiers can be used to detect different objects.
- OpenCV must be installed on the local machine.
- Paths to the classifier XML files must be given before the execution of the program. These XML files can be found in the OpenCV directory “opencv/data/haarcascades”.
- Use 0 in capture.open(0) to play webcam feed.
- For detection in a local video provide the path to the video.(capture.open(“path_to_video”)).