Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The problem was that the image provided was at a different scale to the image that was detected. A classifier has its native window size that it must detect at. This can be exposed publicly in subclass like so:

cv::Size RSCascadeClassifier::windowSize()
{
    cv::Size windowSize = data.origWinSize;

    // Note: this will not work with old format XML classifiers. 

    return windowSize;
}

Then its just a case of resizing the image to the size of this window:

cv::Rect faceRect = objects[0];
cv::Mat foundFaceImage = rotatedFullImage(faceRect).clone();

cv::Size classifierSize = _faceLBPClassifier.windowSize();

cv::Mat scaledFace;
cv::resize(foundFaceImage, scaledFace, classifierSize, 0, 0, INTER_LINEAR);

double weight;
int result = _faceLBPClassifier.runOnceOnWholeImage(scaledFace, weight);

This this fixes the issue 90% of the time, however, sometimes it still wont fully detect the image. I think this is due averaging / merging of a few overlapping rectangles.