OpenCV中未公开的groupRectangles变体 [英] Undocumented groupRectangles variants in OpenCV

查看:60
本文介绍了OpenCV中未公开的groupRectangles变体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在OpenCV的cascadedetect.cpp中,groupRectangles函数有多种变体:

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);

但是在 OpenCV文档中,只有第一个变体已清楚记录,提到了第二个变体,但未解释weights自变量.甚至没有提到第三个.

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.

有人可以解释weightsrejectLevelslevelWeights的含义吗?

Can anyone explain the meanings of weights, rejectLevels, and levelWeights?

推荐答案

我阅读了groupRectangles源代码,并在一定程度上理解了这些参数的含义.

I read the groupRectangles source code and understood the meanings of these parameters to some degree.

groupRectangles在cascadedetect.cpp中定义,OpenCV中的级联项目使用它.该项目使用viola-jones的级联adaboost框架检测对象,因此它具有多个级联阶段,每个阶段都是一个强大的分类器.默认情况下,级联分类器仅在输入样本通过每个阶段时才输出正值,但是如果要绘制ROC曲线,也可以将其设置为输出拒绝样本的阶段的索引.

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.

因此,rejectLevels表示拒绝矩形的阶段的索引.根据源代码,weight的效果与rejectLevels相同.

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.

以上两个参数对我们来说可能不太实用,但是levelWeights有时很有用.它最初是舞台拒绝的矩形输出的分数,但我们可以将其用于更一般的用途.如果每个矩形都有一个分数(无论它来自何处),而我们想获取分组矩形的分数,则已记录的groupRectangles变体将无济于事.我们必须使用第三个,将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);

其中scoreswins的分数.它们大小相同.

In which scores is the scores of wins. They have same size.

这篇关于OpenCV中未公开的groupRectangles变体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆