OpenCV CV 查找单应断言错误计数器 = > 4

OpenCV CV findHomography assertion error counter = > 4

本文关键字:gt 计数器 错误 CV 查找 单应 断言 OpenCV      更新时间:2023-10-16

我正在使用编译和运行来自 Features2D + findHomography 的代码以查找已知对象教程,我得到此错误计数器 => 4 ;我更改了我的代码并在任何地方使用显式命名空间说明符,但问题没有解决。如果可以,请帮助我解决这个问题,或者说哪个函数与findHomography做同样的事情,并且不要使程序崩溃。 这是我的代码 #include "opencv2/opencv.hpp" 使用命名空间 CV;

int main()
{
vector<Point2f> t1;
vector<Point2f> t2;
vector<Point2f> t3;
t3.push_back(Point2f(282, 304));
t1.push_back ( Point2f(249,456));
t1.push_back ( Point2f(264, 330));
t1.push_back ( Point2f(301, 329));
t1.push_back ( Point2f(308, 327));
t1.push_back ( Point2f(293, 249));
t1.push_back ( Point2f(322, 245));
t1.push_back ( Point2f(321, 225));
t1.push_back ( Point2f(266, 228));
t2.push_back ( Point2f(0, 0));
t2.push_back ( Point2f(15, 994));
t2.push_back ( Point2f(105, 994));
t2.push_back ( Point2f(120, 1009));
t2.push_back ( Point2f(90, 2016));
t2.push_back ( Point2f(180, 2031));
t2.push_back ( Point2f(180, 2432));
t2.push_back ( Point2f(0, 2432)); 
//-- Get the corners from t1 t2
vector<Point2f>pt4;
if (t1.size() >=4 && t2.size()>=4 )
{  
Mat h =findHomography(t1, t2, CV_RANSAC, 5);
//-- this may create a mistake;
perspectiveTransform(t3, pt4, h);
for (int m = 0; m < pt4.size(); m++)
cout << pt4[m]<<endl;
}

它可以在调试模式下成功运行,但不能在发布模式下成功运行。怎么了,谢谢。

以这种方式配置,可能会出现调试可以运行但无法在发布下运行的情况(例如没有图片加载、内存错误(,这是 OpenCV 自 2.4.1 以来的错误。如果发生这种情况,打开当前项目(注意当前项目的属性页,而不是公共属性页(,调试或发布错误的,将带有或不带 D 的相应 lib 添加到"当前"工程属性中 ->> [链接器] -> [附加依赖项]