1 | initial version |
Right now, it is a bug in OpenCV.
But if you are using only OpenCV-Python (not Java), there is a temporary solution. I have tested it only with master
branch.
Go to opencv/modules/objdetect/include/opencv2/objdetect.hpp
.
Its line 200 starts as follows :
void detectMultiScale( InputArray image,
Change it to following:
CV_WRAP_AS(detectMultiScale2) void detectMultiScale( InputArray image,
So the final function definition will look like below (especially note 3 CV_OUT macros):
CV_WRAP_AS(detectMultiScale2) void detectMultiScale( InputArray image,
CV_OUT std::vector<Rect>& objects,
CV_OUT std::vector<int>& rejectLevels,
CV_OUT std::vector<double>& levelWeights,
double scaleFactor = 1.1,
int minNeighbors = 3, int flags = 0,
Size minSize = Size(),
Size maxSize = Size(),
bool outputRejectLevels = false );
Now compile it. You will be able to call detectMultiScale2 instead of detectMultiScale in Python as follows:
rects,r,w = cascade.detectMultiScale2(img, scaleFactor=1.3, minNeighbors=4, minSize=(30, 30), flags = cv2.CASCADE_SCALE_IMAGE,outputRejectLevels = 1)