Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV RHO homography method doesn't work with perspectiveTransform

I was trying to use the new RHO homography algorithm in conjunction with perspectiveTransform, but it seems that the homography matrix calculated by RHO has a wrong size and consequently it is not compatible with that method.

See code below:

H = findHomography(obj_points, scn_points, RHO, 1.0);
perspectiveTransform(obj_corners, scene_corners, H);

Following assertion fails:

error: (-215) scn + 1 == m.cols in function perspectiveTransform

Any clue? It works perfectly with RANSAC.

like image 441
Pablo Avatar asked Oct 30 '22 11:10

Pablo


1 Answers

I've found the solution:

With RHO, I have to check the homography matrix to ensure it is not empty. Giving 4 or more points to findHomography is not enough to get an homography matrix with this method.

Although giving to it about 50 matches to compute, it only retrieves a non empty matrix 40-50% of the times.

like image 182
Pablo Avatar answered Nov 15 '22 05:11

Pablo