Ask Your Question
1

How to get the findHomography result's position relative to scene?

asked 2013-07-31 07:53:04 -0600

Ted WONG gravatar image

I follow the following tutorial:

http://docs.opencv.org/doc/tutorials/features2d/feature_homography/feature_homography.html#feature-homography

And I can detect the object I want. But I would like to know the position, and the coordinate is relative in the scene image. And I take the source code's scene_corners vendor, but the position is totally wrong. How can I transfer it the the right position? Thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-07-31 10:17:50 -0600

updated 2013-07-31 10:19:44 -0600

For solve this problem in the first use findHomography() then compute rotation value in the last use perspectiveTransform() to transform object points to scene points.

 const int n = 100;
 Point2f object_points[n],scene_points[n];
  Mat H = findHomography(object_points, scene_points, CV_RANSAC );
  float roatation =  acos( H.at<double>(0,0)) * 180/CV_PI;
  perspectiveTransform( object_points, scene_points, H);
edit flag offensive delete link more

Comments

But what is this line for: float roatation = acos( H.at<double>(0,0)) * 180/CV_PI;

Ted WONG gravatar imageTed WONG ( 2013-08-01 04:58:32 -0600 )edit

It determine the rotation angle of object_points to scene_points.

Mostafa Sataki gravatar imageMostafa Sataki ( 2013-08-01 05:04:41 -0600 )edit

Question Tools

Stats

Asked: 2013-07-31 07:53:04 -0600

Seen: 4,956 times

Last updated: Jul 31 '13