stereolabs / zed-ros-wrapper

ROS wrapper for the ZED SDK
https://www.stereolabs.com/docs/ros/
MIT License
447 stars 391 forks source link

Using openni depth mode results in unrecognized image encoding #494

Closed bsubbaraman closed 4 years ago

bsubbaraman commented 4 years ago

I'm trying to use the openni depth mode with my zed.

First, as a side note, when changing the value in common.yaml, the mode only changes if the value is set to true; when set to 1 as the inline comment says, openni_depth_mode remains disabled. Is this expected?

Second, when interfacing with cv_bridge, trying to use the line cv_ptr = cv_bridge::toCvCopy(_depth_frame_from_sensor) results in the error cv_bridge exception: Unrecognized image encoding []

This line/the rest of my code works fine when openni_depth_mode is false. If I echo depth/depth_raw_registered/encoding, I see that it does indeed change from 32FC1 to mono16.

Am I using openni_depth_mode incorrectly? Any help is greatly appreciated!

Myzhar commented 4 years ago

Hi @bsubbaraman maybe that cv_bridge does not recognize mono16 as image format.

Can you please try to replace MONO16 with TYPE_16UC1 in the following line: https://github.com/stereolabs/zed-ros-wrapper/blob/384347e29c9702725f8943fe0e7439373336244a/zed_wrapper/src/nodelet/src/zed_wrapper_nodelet.cpp#L1423 then recompile and see if it works.

Thank you Walter

bsubbaraman commented 4 years ago

Thanks for the response and idea! Unfortunately, after making the change and recompiling, I get the same error. In fact, even using TYPE_32FC1 gives me the same error, even though that is the encoding that is used when openni_depth_mode is false.

Any other things to try? cv_bridge is supposed to print the name of the unrecognized encoding inside of the brackets [], which leads me to believe that the message is not being made/formatted correctly (my cv_bridge properly prints out 32FC1 when I check the encoding not using openni_depth_mode).

bsubbaraman commented 4 years ago

Additionally, if I change the following line, which is in the method called to publish messages when openni_depth_mode is false:

https://github.com/stereolabs/zed-ros-wrapper/blob/384347e29c9702725f8943fe0e7439373336244a/zed_wrapper/src/tools/src/sl_tools.cpp#L196

to TYPE_16UC1, my code runs fine and depth/depth_raw_registered/encoding properly echoes 16UC1. (This doesn't do any conversion so its not a fix, but confirms that my cv_bridge can accept the proper encoding).

Myzhar commented 4 years ago

Can you please check the encoding field with a debug session? The error message cv_bridge exception: Unrecognized image encoding [] means that the encoding field is empty. I would expect something similar to cv_bridge exception: Unrecognized image encoding [mono16] if the problem is relative to that type of data.

Maybe that there is something weird while copying the data after receiving the topic

bsubbaraman commented 4 years ago

Apologies for the delay- following up to note that I'll report back when I'm able to give this a shot.

Myzhar commented 4 years ago

Closed for inactivity