March 2019
Intermediate to advanced
538 pages
13h 38m
English
To perform object or face detection, first you must load the pretrained XML file using OpenCV's CascadeClassifier class as follows:
CascadeClassifier faceDetector; faceDetector.load(faceCascadeFilename);
This can load Haar or LBP detectors just by giving a different filename. A very common mistake when using this is to provide the wrong folder or filename, but depending on your build environment, the load() method will either return false or generate a C++ exception (and exit your program with an assert error). So it is best to surround the load() method with a try... catch block, and display an error message to the user if something went wrong. Many beginners skip checking for ...