@@ -154,29 +154,30 @@ void EOD_ROS::rgbd_info_cb(const sensor_msgs::ImageConstPtr& rgb_image, const se
154154 ROS_WARN (" Skipped frame" );
155155 return ;
156156 }
157- // TODO add possibility to exclude old stamp images (if detection goes to slow)
158-
157+ // TODO add possibility to exclude old stamp images (if detection goes to slow)
159158 cv::Mat rgb;
160159 try {
161160 rgb = cv_bridge::toCvCopy (rgb_image, " bgr8" )->image ;
162161 }
163162 catch (cv_bridge::Exception& e){
164163 ROS_ERROR (" Could not convert from '%s' to 'bgr8'." , rgb_image->encoding .c_str ());
165164 return ;
166- }
167-
165+ }
168166 cv::Mat depth;
169- if (depth_image->encoding == sensor_msgs::image_encodings::TYPE_16UC1){
170- ROS_INFO (" Depth encoding is 16uc1" );
171- depth = cv_bridge::toCvCopy (depth_image, sensor_msgs::image_encodings::TYPE_16UC1)->image * 0 .001f ;
167+ if (depth_image->encoding == sensor_msgs::image_encodings::TYPE_16UC1){
168+ // ROS_INFO("Depth encoding is 16uc1");
169+ depth = cv_bridge::toCvCopy (depth_image, sensor_msgs::image_encodings::TYPE_16UC1)->image ;
170+ depth.convertTo (depth, CV_32F);
171+ depth *= 0 .001f ;
172172 }
173- else if (depth_image->encoding == sensor_msgs::image_encodings::TYPE_32FC1){
174- ROS_INFO (" Depth encoding is 32fc1" );
173+ else if (depth_image->encoding == sensor_msgs::image_encodings::TYPE_32FC1){
174+ // ROS_INFO("Depth encoding is 32fc1");
175175 depth = cv_bridge::toCvCopy (depth_image, sensor_msgs::image_encodings::TYPE_32FC1)->image ;
176176 }
177177 else {
178178 ROS_ERROR_THROTTLE (5 , " Depth image has unsupported encoding [%s]" , depth_image->encoding .c_str ());
179179 }
180+ // ROS_INFO("Depth type is %i", depth.type());
180181 eod::InfoImage ii_rgb = eod::InfoImage (rgb, getK (rgb_info), getD (rgb_info) );
181182 eod::InfoImage ii_depth = eod::InfoImage (depth, getK (depth_info), getD (depth_info) );
182183 detect (ii_rgb, ii_depth, rgb_image->header );
0 commit comments