Search code examples
opencvvideo-processingcascadehaar-wavelethaar-classifier

OpenCV Haar Classifier - how does it know when an object has been matched in live video


I have a trained OpenCV Haar Classifier, I am using the sample face detect program and supplying my classifier xml file as an argument. The program is working as expected, my question is how does the program know when the object has been detected?

Does it use the Haar feature rectangles on the live video feed and check for a feature match within the XML?


Solution

  • Without getting too technical, it runs a sliding window on each frame and for each window, it applies a list of simple classifiers. If the result of all the classifiers was that there is indeed a face in the window, then that window is considered a candidate. After allying the list of classifiers, the algorithm tries to merge candidates. If it succeeded in merging (there were enough candidates that were close to each other), then it outputs a detection.