ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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);