OpenCV findContour给出了奇怪的结果
OpenCV findContour giving weird results
我试图在深度图像上放置一个简单的边界框:
void cropAndResize(const cv::Mat &input, cv::Mat &output) {
std::vector<std::vector<cv::Point> > contours;
cv::Rect croppedHand;
cv::findContours(input, contours,CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
int maxCont = -1;
if (contours.size() != 0) {
maxCont = 0;
}
for (int i = 0; i < contours.size(); i++) {
int currSize = contours.at(i).size();
if (contours.at(maxCont).size() < currSize)
maxCont = i;
}
if (maxCont > -1) {
croppedHand = cv::boundingRect(contours.at(maxCont));
}
}
boundingRect给了我一个断言失败(points.checkVector(2)>=0&;(points.depth()==CV_23F||points.depth()==CV_32S))。
这很奇怪,因为我很确定这个代码以前工作过。所以我检查了contours
的内容,结果令人困惑。一些元素是大小为452126096252493236或更大的向量。检查向量,我主要有这样的点{x=??,y=???}。
findCountours有什么问题吗?我使用的是Visual Studio 2013、Windows 8 Pro、OpenCV 2.4.8。
编辑:输入图像为CV_8UC1。
因此,对于其他有此问题的人,我通过返回VS2010来解决它。OpenCV似乎无法跟上当前的技术。
相关文章:
- 为什么"do while"循环不断退出,即使条件计算结果为 false?
- valgrind-hellgrind与泄漏检查的结果不同
- 用C++20 fmt限制结果的总大小
- 如何返回一个类的两个对象相加的结果
- 使用QProcess执行命令,并将结果存储在QStringList中
- 如果我std::dynamic_pointer_cast并且底层dynamic_cast的结果为null,那么返回的sh
- 在没有定义返回类型的函数中返回布尔值,并将结果保存在无错误的char编译中-为什么
- 序列化,没有库的整数,得到奇怪的结果
- 使用取消引用的指针的多态性会产生意外的结果.为什么?
- 在更改for循环的第三部分后,未使用for循环结果
- 使用++运算符会导致意外的结果
- 为什么在逗号分隔符上下文中将预增量的结果强制转换为void
- C++Brute Force攻击函数不会返回结果
- 你好。。。id_public变量不应该给出结果为 81 和 86 吗?为什么它为两个派生类占用不同的内存位置?
- 算术运算的结果类似于:C浮点变量中的1/3
- ";结果类型必须是可从输入范围的值类型""构造的;创建std::vector时
- 密码登录程序将永远循环并显示不正确的结果
- 如何让C++'tally up'结果并制定计划?
- 为什么这个程序的结果是3 "born"?和 4 死
- OpenCV findContour给出了奇怪的结果