Ask Your Question

"sensor_msgs::ImageConstPtr" encoding and type casting

asked 2012-10-22 23:50:14 -0500

raminzohouri gravatar image

Hi all in my program I subscribe this topic "/camera/depth/image" and I want to use this image for visual optometry in Fovis.

I use this function parameter "sensor_msgs::ImageConstPtr depth_image" and the encoding of this topic "depth_image->encoding.c_str()" is "32FC1" .

how cant I cast this type to "const uint16_t" ? and also for similar types like " 8UC[1-4],8SC[1-4],16UC[1-4],16SC[1-4],32SC[1-4],32FC[1-4],64FC[1-4]" ?

thank you in advance Ramin

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-10-23 00:01:00 -0500

Thomas gravatar image

Take a look at cv_bridge tutorial to know how to properly convert images from one colorspace to another.

I would recommend you to make your package depend on cv_bridge, create an OpenCV image whose internal representation matches what Fovis expects and then pass the internal data representation to Fovis.

Be particularly attentive regarding how this data is accessed, allocated and freed, it may be necessary to make an additional copy of the image depending on the memory management strategy of both OpenCV and Fovis.

edit flag offensive delete link more

answered 2012-11-05 03:03:17 -0500

raminzohouri gravatar image

Hi Thomas Thank you for your response.Its the type casting works for me and I get data that I want for Fovis .However I found that the topic ""/camera/depth/image" which I subscribe from a bag file is return rectified depth data and Fovis itself rectified data as well so its end up with a odometry far away from grand truth.

I may record those bag file in the row format and then try to rectify them in my program .

edit flag offensive delete link more


Please edit your question instead of posting answers. Is there any way for FOVIS to use already calibrated data? It would be by far the better and safest solution.

Thomas gravatar image Thomas  ( 2012-11-05 22:02:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2012-10-22 23:50:14 -0500

Seen: 1,530 times

Last updated: Nov 05 '12