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

Project point cloud to image coordinates using camerainfo

asked 2014-03-04 06:14:45 -0500

jpo gravatar image

updated 2014-03-05 01:45:42 -0500

Hi, I'm new to ROS (and PCL as well) so sorry if the question is too trivial...but I've been searching for quite a long time and couldn't find an answer..

I have the pointcloud and I need to project it to the image coordinates with corresponding CameraInfo. I found there is K (intrinsic) matrix which I should use for multiplication the coordinates (K*[x y z]^transposed) but the results don't seem to be correct...

EDIT: Okay, I followed the tutorial and now I have something like

PointCloud<PointXYZI>::Ptr output_xyz(new PointCloud<PointXYZI>); // init PointCloud
sensor_msgs::CameraInfo cam_info; // init CameraInfo
.... // do some processing
image_geometry::PinholeCameraModel cam_model; // init cam_model
cam_model.fromCameraInfo(cam_info); // fill cam_model with CameraInfo
cv::Point3d pt_cv(output_xyz->at(0).x, output_xyz->at(0).y, output_xyz->at(0).z);//init Point3d
cv::Point2d uv = cam_model.project3dToPixel(pt_cv); // project 3d point to 2d point

and I'm getting an assertion error "Assertion `P_(2, 3) == 0.0' failed" . That is obvious because my cam_model.projectionMatrix() looks like this

[868.9074096679688, 0, 641.492403333923, 0;
0, 879.0201416015625, 542.1365647019775, 0;
0, 0, 1, 1]

I think there is no problem with CameraInfo, because rviz displays the pointcloud correctly in the image with it, but I probably need to do yet some other manipulation to get the correct result. Don't you know what might be the problem?

Thanks in advance, JP

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2014-03-04 07:01:41 -0500

I recommend reading the information on the image_geometry wiki page. If you follow the conventions stated there, you´ll be able to easily use the project3dToPixel function to achieve your goal.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-03-04 06:14:45 -0500

Seen: 5,487 times

Last updated: Mar 05 '14