36 #include <dvo/dense_tracking.h> 37 #include <dvo/core/surface_pyramid.h> 38 #include <dvo/core/rgbd_image.h> 51 motionFromKeyFrame_(
Transform::getIdentity())
104 UERROR(
"Not supported input!");
110 UERROR(
"Invalid camera model! Only single RGB-D camera supported by DVO. Try another odometry approach.");
116 dvo::DenseTracker::Config cfg = dvo::DenseTracker::getDefaultConfig();
118 dvo_ =
new dvo::DenseTracker(cfg);
121 cv::Mat grey, grey_s16, depth_inpainted, depth_mask, depth_mono, depth_float;
122 if(data.
imageRaw().type() != CV_32FC1)
124 if(data.
imageRaw().type() == CV_8UC3)
126 cv::cvtColor(data.
imageRaw(), grey, CV_BGR2GRAY);
133 grey.convertTo(grey_s16, CV_32F);
141 if(data.
depthRaw().type() == CV_32FC1)
144 for(
int i=0; i<depth_float.rows; ++i)
146 for(
int j=0; j<depth_float.cols; ++j)
148 float &
d = depth_float.at<
float>(i,j);
156 else if(data.
depthRaw().type() == CV_16UC1)
158 depth_float = cv::Mat(data.
depthRaw().size(), CV_32FC1);
159 for(
int i=0; i<data.
depthRaw().rows; ++i)
161 for(
int j=0; j<data.
depthRaw().cols; ++j)
163 float d = float(data.
depthRaw().at<
unsigned short>(i,j))/1000.0f;
164 depth_float.at<
float>(i, j) = d==0.0
f?NAN:d;
170 UFATAL(
"Unknown depth format!");
175 dvo::core::IntrinsicMatrix intrinsics = dvo::core::IntrinsicMatrix::create(
180 camera_ =
new dvo::core::RgbdCameraPyramid(
186 dvo::core::RgbdImagePyramid * current =
new dvo::core::RgbdImagePyramid(*camera_, grey_s16, depth_float);
192 reference_ = current;
197 covariance = cv::Mat::eye(6,6,CV_64FC1) * 9999.0;
201 dvo::DenseTracker::Result result;
202 dvo_->match(*reference_, *current, result);
205 if(result.Information(0,0) > 0.0 && result.Information(0,0) != 1.0)
208 cv::Mat information = cv::Mat::eye(6,6, CV_64FC1);
209 memcpy(information.data, result.Information.data(), 36*
sizeof(double));
211 covariance = cv::Mat::eye(6,6,CV_64FC1);
212 covariance = information.inv().mul(covariance);
227 reference_ = current;
245 covariance = cv::Mat::eye(6,6,CV_64FC1) * 9999.0;
246 UWARN(
"dvo failed to estimate motion, tracking will be reinitialized on next frame.");
258 t = localTransform * t * localTransform.
inverse();
273 UERROR(
"RTAB-Map is not built with DVO support! Select another visual odometry approach.");
virtual void reset(const Transform &initialPose=Transform::getIdentity())
virtual Transform computeTransform(SensorData &image, const Transform &guess=Transform(), OdometryInfo *info=0)
std::map< std::string, std::string > ParametersMap
const cv::Mat & imageRaw() const
Wrappers of STL for convenient functions.
OdometryDVO(const rtabmap::ParametersMap ¶meters=rtabmap::ParametersMap())
Transform previousLocalTransform_
const cv::Mat & depthOrRightRaw() const
Transform motionFromKeyFrame_
const std::vector< CameraModel > & cameraModels() const
ULogger class and convenient macros.
virtual void reset(const Transform &initialPose=Transform::getIdentity())