stereo_odometry: for rgbd_image input, make sure all image data are copied in callback.

This commit is contained in:
matlabbe
2021-11-24 10:02:45 -05:00
parent 4f4f72837d
commit 8a75963739
+15 -7
View File
@@ -419,32 +419,40 @@ private:
}
}
cv_bridge::CvImageConstPtr ptrImageLeft = imageRectLeft;
cv::Mat left;
if(imageRectLeft->encoding.compare(sensor_msgs::image_encodings::TYPE_8UC1) !=0 &&
imageRectLeft->encoding.compare(sensor_msgs::image_encodings::MONO8) != 0)
{
if(keepColor_ && imageRectLeft->encoding.compare(sensor_msgs::image_encodings::MONO16) != 0)
{
ptrImageLeft = cv_bridge::cvtColor(imageRectLeft, "bgr8");
left = cv_bridge::cvtColor(imageRectLeft, "bgr8")->image;
}
else
{
ptrImageLeft = cv_bridge::cvtColor(imageRectLeft, "mono8");
left = cv_bridge::cvtColor(imageRectLeft, "mono8")->image;
}
}
cv_bridge::CvImageConstPtr ptrImageRight = imageRectRight;
else
{
left = imageRectLeft->image.clone();
}
cv::Mat right;
if(imageRectLeft->encoding.compare(sensor_msgs::image_encodings::TYPE_8UC1) !=0 &&
imageRectLeft->encoding.compare(sensor_msgs::image_encodings::MONO8) != 0)
{
ptrImageRight = cv_bridge::cvtColor(imageRectRight, "mono8");
right = cv_bridge::cvtColor(imageRectRight, "mono8")->image;
}
else
{
right = imageRectRight->image.clone();
}
UTimer stepTimer;
//
UDEBUG("localTransform = %s", localTransform.prettyPrint().c_str());
rtabmap::SensorData data(
ptrImageLeft->image,
ptrImageRight->image,
left,
right,
stereoModel,
0,
rtabmap_ros::timestampFromROS(stamp));