Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a score for cv2.CascadeClassifier.detectMultiScale()?

When using Python,

the openCV function

cv.HaarDetectObjects()

returns an object found along with a detection score.

If I use the opencv2 function instead,

cv2.CascadeClassifier.detectMultiScale()

I get the detected object, but no score. This makes it difficult to get a good "confidence" measure of the detection.

Is there a way to get that somehow, using CV2?

like image 319
eran Avatar asked Nov 29 '12 07:11

eran


1 Answers

According the documentation

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

The list rejectLevels is kind of scores indicating the confidence of detection result.

The corresponding (however undocumented) C++ API is:

CV_WRAP virtual void detectMultiScale( const Mat& image,
                               CV_OUT vector<Rect>& objects,
                               vector<int>& rejectLevels,
                               vector<double>& levelWeights,
                               double scaleFactor=1.1,
                               int minNeighbors=3, int flags=0,
                               Size minSize=Size(),
                               Size maxSize=Size(),
                               bool outputRejectLevels=false );
like image 155
Zifei Tong Avatar answered Nov 16 '22 01:11

Zifei Tong