Search code examples
c++opencvface-detectionconfidence-interval

Calculating confidence factor in Viola–Jones face detection?


I am trying to use Viola–Jones face detection algorithm in OpenCV. I use the detectMultiScale() to locate multiple faces in image. I am wondering how is it possible to return from the source code or to calculate a confidence factor for the face that are calculated. It seems that by default detectMultiScale() function doesn't return a conf factor.


Solution

  • There is no confidence score to return but you can set how confident you want by setting minNeighbors. The higher, the better quality, also the less faces.

    • minNeighbors – Parameter specifying how many neighbors each candidate rectangle should have to retain it (documentation).

    Edit: If you use Python, you can modify the quality by setting rejectLevels.

    Python: cv2.CascadeClassifier.detectMultiScale(image, rejectLevels, 
        levelWeights[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize[,      
        outputRejectLevels]]]]]]) → objects