ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

problems with the ray in projectPixelTo3dRay

asked 2011-05-03 11:06:03 -0600

Javier Romero gravatar image

updated 2014-01-28 17:09:37 -0600

ngrennan gravatar image

According to the API, the return value is "the unit vector in the camera coordinate frame in the direction of rectified pixel" (from 1.4 is not unit, but with unit z component). I expected that multiplying such a vector by a scalar z would give me the 3D point with depth z that projects into the input pixel. However, when i back-project such a vector the result is not the input pixel:

cv::Point2d pixel(r,c);
cv::Point3d ray =  model.projectPixelTo3dRay(pixel);
cv::Point3d point = ray * z;
cv::Point2d back_pixel = model.project3dToPixel(point);

I would expect back_pixel be equal to pixel for any z, but it only happens for z=1. Have I misunderstood something?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2011-05-03 12:34:50 -0600

Javier Romero gravatar image

OK, it's pretty straightforward if you look at the code of the functions. The problem is that I was looking to the second camera of a stereo pair, and therefore the components Tx is non-zero. Therefore you have to make a couple of translations:

cv::Point2d pixel(r,c);
cv::Point3d ray =  model.projectPixelTo3dRay(pixel);
float tx_fx = model.Tx()/model.fx();
cv::Point3d point(z*(ray.x+tx_fx)-tx_fx,z*ray.y,z*ray.z);
cv::Point2d back_pixel = model.project3dToPixel(point);
edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-05-03 11:06:03 -0600

Seen: 1,514 times

Last updated: May 03 '11