/tof_depth image conversion problem
-
Hello,
I would like to convert the depth image from mono8 to UC16 while maintaining accurate depth references.
Currently, I am doing this, but I am ending up with a flat image.void depthCallback(const sensor_msgs::ImageConstPtr &msg) { try { // Convert the input ROS image to an OpenCV image cv_bridge::CvImagePtr cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::MONO8); // Create a new image in CV_16UC1 format cv::Mat converted_image; cv_ptr->image.convertTo(converted_image, CV_16UC1, 256.0); // Scale mono8 values to 16-bit // Publish the converted image cv_bridge::CvImage out_msg; out_msg.header = msg->header; // Keep the same header out_msg.encoding = sensor_msgs::image_encodings::TYPE_16UC1; out_msg.image = converted_image; depth_pub_.publish(out_msg.toImageMsg()); // depth_pub_.publish(depth_msg); } catch (cv_bridge::Exception &e) { ROS_ERROR("CvBridge Error in depthCallback: %s", e.what()); } }
Also, I want to mix it with an RGB image to get an RGBD image, I'm using the rgbdsync nodelet from rtabmap_ros. But I'm unable to make it work. Does someone already did that ?
Julien -
Can you help me with the depth image conversion ?