Ask Your Question

Publish depth image CV_32F using cv_bridge

asked 2015-08-01 08:14:27 -0500

rbaleksandar gravatar image


Working environment: Kubuntu 14.04 LTS ROS Indigo (up-to-date, full desktop install) OpenCV 2.4.8 (default from the repos)

I have a PMD nano here and managed to get it up and running using the great library rgbd-grabber by Yutaka Kondo. It displays 3 things - amplitude (as cv::Mat), depth (as cv::Mat) and point cloud (as PCL cloud). Now I'm trying to integrate only the PMD part of his library in my ROS infrastructure. For this purpose I have created a wrapper node around the PMDNano class, which basically has to take the output of that class (the three data structures I have mentioned above) and publish those on my ROS network. I haven't started on the point cloud part yet since I have noticed that cv_bridge has actually very limited support for the various encodings OpenCV offers. As I reference I am using the cv_bridge.cpp file since the ROS documentation doesn't say a lot about the encodings. I am also using this tutorial.

In the tutorial the cv::Mat image is converted to a ROS image and encoded with the string "bgr8". I however have a CV_32F at my disposal. Now as far as I know what I have here is a 32bit float at hand while the encodings provided by cv_bridge go as far as 16bit (example: MONO16).

My question is basically if it will be a problem to go to "mono8" in this case especially considering that the published imagery is meant just for viewing and no further processing will be done with it? If it is a problem, then how do I covert CV_32F using cv_bridge's available encodings?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-08-01 10:14:32 -0500

I guess you should convert it yourself, Why? Well I for example have a 16bit image of a thermal camera. Of course there is a function to convert it to mono8. BUT. If you convert it you lose a lot of space, lets say all the values of your picture lay between 100-500. Now you convert the 32 to 8 bits space... -> you will get a totally dark grey (almost black) image. You will lose the steps in between!

So for viewing it, it will be complete rubbish, well if the values are in big jumps like 1000 -> 10000 (not normal not for a real world image)

I guess you should specifiy some function to check where your values are, and color/grey them in that range. So you will still be able to see something.

Viewing in that case is more difficult then just processing ;-)



edit flag offensive delete link more


Thanks, I guess I have to do that. I tried mono8 and mono16 but the results looks like garbage. :D Pity the encodings supported by ROS Image don't support more of OpenCV's ones.

rbaleksandar gravatar image rbaleksandar  ( 2015-08-04 10:12:51 -0500 )edit

You're welcome.

cyborg-x1 gravatar image cyborg-x1  ( 2015-08-04 10:38: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


Asked: 2015-08-01 08:14:27 -0500

Seen: 1,204 times

Last updated: Aug 01 '15