kinecvt v2 depth messages are mono16, not TYPE_16UC1

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

kinecvt v2 depth messages are mono16, not TYPE_16UC1

phila
When i tried to run :
roslaunch rtabmap_ros rgbd_mapping_kinect2.launch

i kept getting an error about the image encoding, but and when i looked, i saw the depth had an encoding of mono16, not
TYPE_16UC1, as was expected. This is from the kinect2_bridge application.

So I changed all TYPE_16UC1 to MONO16 in the code, and added "mono16" to the cv_bridge lines, like:
 cv_bridge::CvImageConstPtr ptrDepth = cv_bridge::toCvShare(depth, "mono16");


does this look okay?

Now when i run i don't get any errors, but I don't think the point cloud is being built correctly.
Most of the time their is no cloud in the main part ofo the window, and sometimes it is there, but rotated 90 and translated pretty far from what I am currently pointing the camera at

Here are some screen shots(4) of a progression of one run of the program
https://github.com/pammirato/rtabmap_ros/tree/master/screenshots
Reply | Threaded
Open this post in threaded view
|

Re: kinecvt v2 depth messages are mono16, not TYPE_16UC1

matlabbe
Administrator
I checked the kinect2_bridge code and depth images are supposed to be TYPE_16UC1 (see here). What is exactly the error?

Well, TYPE_16UC1 in sensor_msgs is mono16 in OpenCV (or CV_16UC1). Your patch is ok though. I will add your changes as the depth images (if they are TYPE_32FC1) are eventually converted to CV_16UC1 anyway in the rtabmap library.

For the 90 rotation, make sure that TF is published by kinect2_bridge. See publish_tf parameter.

$ roslaunch rtabmap_ros rgbd_mapping_kinect2.launch
$ rosrun kinect2_bridge kinect2_bridge  _publish_tf:=true
or
$ roslaunch kinect2_bridge kinect2_bridge.launch  publish_tf:=true
$ roslaunch rtabmap_ros rgbd_mapping_kinect2.launch

As a side note, make sure the camera is calibrated.
Reply | Threaded
Open this post in threaded view
|

Re: kinecvt v2 depth messages are mono16, not TYPE_16UC1

matlabbe
Administrator
Well I was wrong, you cannot convert to "mono16" because TYPE_16UC1 is not an image type recognized by cv_bridge:
terminate called after throwing an instance of 'cv_bridge::Exception'
  what():  [16UC1] is not a color format. but [mono16] is. The conversion does not make sense
Reply | Threaded
Open this post in threaded view
|

Re: kinecvt v2 depth messages are mono16, not TYPE_16UC1

phila
In reply to this post by matlabbe
Problem was I was using the 'devel' branch of kinect2_bridge, which publishes depths as MONO16.

swtiched to master and it works. thanks
Reply | Threaded
Open this post in threaded view
|

Re: kinecvt v2 depth messages are mono16, not TYPE_16UC1

matlabbe
Administrator
Thanks, good to know. I will still add MONO16 to the accepted format on rtabmap side.