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

Does ROS have convenience function calls to convert from world XYZ to camera XY using the camera_info message?

asked 2011-04-11 05:45:30 -0600

The information is available in the camera_info message, but using standard functionality to convert would be much less error prone, and much less sloppy. Does such functionality exist?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
5

answered 2011-04-11 06:04:38 -0600

Eric Perko gravatar image

The image_geometry package contains helpers to do this.

There is a tutorial for how to project the XYZ origin of a reference frame into an image, so it should be an excellent example for what you described.

edit flag offensive delete link more
2

answered 2011-04-21 10:53:28 -0600

It turns out the "P" matrix in the camera_info message does this more or less directly. I was able to do the needed transformation this way:

From the camera_info callback

m_worldToCamera = Eigen::Matrix<double,3,4,Eigen::RowMajor>( msg->P.data() );

And then later

Eigen::Vector3d imgPoint;
cameraPoint = m_worldToCamera * Eigen::Vector4d( point.x(), point.y(), point.z(), 1 );

Eigen::Vector2d flatPoint;
flatPoint.x() = cameraPoint.x() / cameraPoint.z();
flatPoint.y() = cameraPoint.y() / cameraPoint.z();
edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-04-11 05:45:30 -0600

Seen: 1,353 times

Last updated: Apr 21 '11