In cascadedetect.cpp in OpenCV, there are several variants of groupRectangles
function:
void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, double eps);
void groupRectangles(std::vector<Rect>& rectList, std::vector<int>& weights, int groupThreshold, double eps);
void groupRectangles(std::vector<Rect>& rectList, std::vector<int>& rejectLevels, std::vector<double>& levelWeights, int groupThreshold, double eps);
But in the OpenCV document, only the first variant is documented clearly, the second variant is mentioned but the weights
argument is not explained. The third isn't even mentioned.
Can anyone explain the meanings of weights
, rejectLevels
, and levelWeights
?
I read the groupRectangles
source code and understood the meanings of these parameters to some degree.
groupRectangles
is defined in cascadedetect.cpp, which is used by traincascade project in OpenCV. This project uses viola-jones's cascaded adaboost framework to detect objects, thus it has several cascade stages, and each of them is a strong classifier. The cascade classifier by default outputs positive only if the input sample passed every stage, but you can also set it to output the index of stage at which the sample is rejected if you want to plot a ROC curve.
So rejectLevels
means the index of stage at which the rectangle is rejected. According to source code, the effect of weight
is same as rejectLevels
.
The above two parameters may not be very practical for us, but levelWeights
is sometimes useful. It's originally the score of the rectangle outputted by the stage which rejects it, but we can use it for a more general purpose. If every rectangle has a score(no matter where it comes from), and we want to get the scores of grouped rectangles, the documented variant of groupRectangles
won't help us. We must use the third one, with rejectLevels
set to zeros:
vector<int> levels(wins.size(), 0);
groupRectangles(wins, levels, scores, groupThreshold, eps);
In which scores
is the scores of wins
. They have same size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With