I'm using a trained opencv cascade classifier to detect hands in video frames, and would like to lower my false positive rate.
Reading up on the net, I saw you can do so by accessing the
rejectLevels
and levelWeights
information returned by the detectMultiScale method. I saw here that this is possible in C++, my question is- has anyone managed to do it in Python? A similar question was asked here but it was for an earlier version of of the detection method.
If it is possible, what is the proper syntax to call the method? If it worked for you, please mention the OpenCV version you're using. I'm on 2.4.9.
The 2.4.11 API gives the following syntax
Python: cv2.CascadeClassifier.detectMultiScale(image, rejectLevels, levelWeights[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize[, outputRejectLevels]]]]]])
So accordingly, I've tried
import cv2
import cv2.cv as cv
import time
hand_cascade = cv2.CascadeClassifier('cascade.xml')
img = cv2.imread('test.jpg')
rejectLevels = []
levelWeights = []
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = hand_cascade.detectMultiScale(gray,rejectLevels,levelWeights, 1.1, 5,cv.CV_HAAR_FIND_BIGGEST_OBJECT,(30, 30),(100,100),True)
But the output I get is
[[259 101 43 43]
[354 217 43 43]
[240 189 43 43]
[316 182 47 47]
[277 139 92 92]]
[]
[]
Thanks for the help,
Ronen