【问题标题】:OpenCV CV findHomography assertion error counter = > 4OpenCV CV findHomography 断言错误计数器 = > 4
【发布时间】: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)。

标签: c++ opencv


【解决方案1】:

这样配置,可能会出现debug可以运行但release下不能运行的情况(比如没有图片加载,内存错误),这是OpenCV从2.4.1开始的一个bug。如果出现这种情况,打开当前工程(注意是当前工程的属性页,不是通用属性页),debug或者release有问题,在“当前”工程属性中添加对应的带或不带D的lib-> [链接器] -> [附加依赖]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-21
    • 1970-01-01
    • 2012-10-20
    • 1970-01-01
    • 2020-08-21
    • 2017-12-24
    • 2021-02-26
    • 2016-02-21
    相关资源
    最近更新 更多