homography unbounded values observed

asked 2018-06-13 01:47:07 -0500

pranan gravatar image

I get different outputs for cvFindHomography() and findHomography() (C++). findHomography produces big floating point numbers whereas cvFindHomography produces smaller values. why? I have copied the code and its corresponding outputs below. Request for help and thanks in advance.

Code:1

double h[9];

CvMat _h = cvMat(3, 3, CV_64F, h);

std::vector < CvPoint2D32f > pt1, pt2;

CvMat _pt1, _pt2;

_pt1 = cvMat(1, nCnt, CV_32FC2, &pt1[0]);

_pt2 = cvMat(1, nCnt, CV_32FC2, &pt2[0]);

cvFindHomography( &_pt1, &_pt2, &_h, CV_RANSAC, 1)

Values returned in _h printed using cout

0.999928 0.000027 0.013392

0.000018 0.999958 -0.005272

-0.000000 -0.000000 1.000000

Code:2

Mat H(3, 3, CV_64F);

std::vector < Point2f > pt1, pt2;

findHomography(pt1, pt2, &H, RANSAC, 1);

Values returned in H printed using cout

0.000000 1.874995 0.000000

-0.488446 0.000000 1.175271

0.000000 0.520783 -6536181216787541205712896.000000

edit retag flag offensive close merge delete

Comments

whatever you get from opencv's deprecated c-api, it's irrelevant. you should NEVER use code like that, and it will most likely no more be there in the next opencv version.

berak gravatar imageberak ( 2018-06-13 01:57:54 -0500 )edit

Thank you for the response. You mean findHomography() shall not be used?

So we shall use only cvFindHomography().

pranan gravatar imagepranan ( 2018-06-13 03:33:14 -0500 )edit

no, the absolute opposite , ofc.

opencv moved away from c in 2010 already

berak gravatar imageberak ( 2018-06-13 03:36:39 -0500 )edit

Ok. That means the big numbers given by findHomography () function are supposed to be correct?

pranan gravatar imagepranan ( 2018-06-13 03:42:50 -0500 )edit

impossible to say, without seing your input data (your code is not reproducable)

berak gravatar imageberak ( 2018-06-13 03:55:00 -0500 )edit