Ask Your Question
0

Converting solvePnP tvec

asked 2014-11-02 16:44:47 -0600

_chris gravatar image

updated 2014-11-04 02:46:37 -0600

I am using solvePnP to figure the rotation and translation of a fiducial marker relative to my camera (a Kinect). I understand that the units it will return for translation are the same as those I pass in, which in my case I think is the camera intrinsics:

solvePnP(Mat(markerPoints), Mat(sceneCorners), intrinsics, distortion,rvec, tvec, false);

How can I convert the translation result to real world distance? Would I have to basically apply the fundamental camera matrix or is there a simple scaling factor I can apply? My current thought is to multiply tvec by the size of the marker (in my case an 8cmx8cm, so multiply by 8).

EDIT:

Having gained a bit more understanding, here is what markerPoints are:

//FID_SIZE = 8.0cm
markerPoints.push_back( Point3f( 0.0, 0.0, 0.0 ) );
markerPoints.push_back( Point3f( FID_SIZE, 0.0, 0.0 ) );
markerPoints.push_back( Point3f( FID_SIZE, FID_SIZE, 0.0 ) );
markerPoints.push_back( Point3f( 0.0, FID_SIZE, 0.0 ) );

And sceneCorners are in pixels. Still can't quite get it to make 100% sense.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-11-03 03:05:10 -0600

updated 2014-11-03 07:44:21 -0600

The easiest way is to pass the markerPoints in meters. If you have a checkerboard with 9*9 corners and 9cm, your point would be something like [(-0.04,-0.04),(-0.03,-0.04),...,(0.04,0.04)]. In this case, your translation vector will also be given in meters.

edit flag offensive delete link more

Comments

I get where you're coming from, in the code I had it was placing stuff at (1.0,0) etc. Where did the 4 / 3 come from if the squares are 9 cm? And the negatives as well?

_chris gravatar image_chris ( 2014-11-04 01:51:42 -0600 )edit

I was refering to a board where each square has an area of 1cm*2. (and your board would have a size of 8cm8cm, so don't bother the details). I set the origin of the board in its center (which is imho better than having it in one of the corners, but that definition is completely up to you)

FooBar gravatar imageFooBar ( 2014-11-04 03:06:11 -0600 )edit

so if i offset my markerPoints all by half of the size it should give me the origin in the centre of the marker?

_chris gravatar image_chris ( 2014-11-04 03:15:20 -0600 )edit

yes. These points define your marker-based coordinate system.

FooBar gravatar imageFooBar ( 2014-11-04 04:29:20 -0600 )edit

Question Tools

Stats

Asked: 2014-11-02 16:44:47 -0600

Seen: 551 times

Last updated: Nov 04 '14