# Converting solvePnP tvec

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 close merge delete

Sort by ยป oldest newest most voted

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.

more

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?

( 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)

( 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?

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

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

( 2014-11-04 04:29:20 -0600 )edit

Official site

GitHub

Wiki

Documentation