【发布时间】:2018-06-20 04:25:02
【问题描述】:
我正在使用 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;
}
它可以在调试模式下成功运行,但不能在发布模式下运行。怎么回事谢谢。
【问题讨论】:
-
而不是 CV_RANSAC 使用 0(使用所有对),它应该在调试中失败并在发布中运行。在调试模式下,断言会运行并跳转,而在发布期间则不会。
-
@api55 但是,当我使用 0 时,它也会在 cvfindhomography 中出错:(count>=4)。