简体   繁体   中英

OpenCV CV findHomography assertion error counter = > 4

I am using to compile and run code from Features2D + findHomography to find a known object tutorial, and I am getting this error counter = > 4 ;and I changed my code and use everywhere explicit namespace specifiers, but problem did not solved. If you can, please help me in this problem, or say which function do same thing as findHomography, and do not crash program. And this is my code #include "opencv2/opencv.hpp" using namespace 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;
 }

It can run successfully in debug mode but not in release mode. What's the matter with it thanks.

Configured in this way, there may be a situation where debug can run but can't run under release (such as no picture loading, a memory error), which is a bug from OpenCV since 2.4.1. If this happens, open the current project (notice the property page of the current project, not the common attribute page), debug or release which is wrong, add the corresponding lib with or without D to the "current" engineering properties - > > [linker] - > [additional dependency]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM