LDSO《Direct Sparse Odometry with Loop Closure》安装编译与数据集运行(ubuntu16.04+opencv3.2.0)

LDSO是高博最近在TUM做出的成果,将原始的DSO直接视觉里程记方法加入闭环检测。下面就来记录以下LDSO的编译运行吧

首先当然是从GITHUB上爬下来源码:

git clone https://github.com/tum-vision/LDSO LDSO

然后进入该文件夹****/LDSO,运行

./install_dependencies.sh

确保你电脑里已经安装了Pangolin,如果没有,请翻看之前的博客:

然后就是运行编译脚本

./make_project.sh

如果这时候没有报错的话,已经完成一大半了,然后下载TUM-Mono的数据集dataset sequence 34

https://vision.in.tum.de/mono-dataset

之后进入在该LDSO文件目录下放入sequence 34,运行指令

./bin/run_dso_tum_mono \
    preset=0 \
    files=sequence_34/images.zip \
    vignette=sequence_34/vignette.png \
    calib=sequence_34/camera.txt \
    gamma=sequence_34/pcalib.txt

这样就可以跑起来啦。

但是到这里我个人电脑上会出现一点问题,运行过程终会随机报错

I0319 19:39:24.154325 10779 LoopClosing.cc:125] candidate kf id: 37, max id: 116, min id: 104
I0319 19:39:24.155541 10779 LoopClosing.cc:133] add loop candidate from 37, current: 117, score: 0.0316569
I0319 19:39:24.156579 10779 LoopClosing.cc:166] matches: 18

OpenCV Error: Assertion failed (confidence > 0 && confidence < 1) in run, file /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/calib3d/src/ptsetreg.cpp, line 178
I0319 19:39:24.162940 10780 FullSystem.cc:73] *** taking frame 326 ***
I0319 19:39:24.169001 10780 FullSystem.cc:107] swap coarse tracker to 325
I0319 19:39:24.169020 10780 FullSystem.cc:114] tracking new frame
terminate called after throwing an instance of 'cv::Exception'
  what():  /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/calib3d/src/ptsetreg.cpp:178: error: (-215) confidence > 0 && confidence < 1 in function run

也就是说一旦涉及到LoopClosing.cc的相关工作时就会出现OPENCV Error,我分析是因为Opencv版本问题。

也定位到了**/LDSO/src/frontend/LoopClosing.cc的203行

cv::solvePnPRansac(p3d, p2d, K, cv::Mat(), R, t, false, 100, 8.0, 0, inliers);

根据Opencv关于solverPnPRansac函数的定义

CV_EXPORTS_W void solvePnPRansac( InputArray objectPoints,
                                  InputArray imagePoints,
                                  InputArray cameraMatrix,
                                  InputArray distCoeffs,
                                  OutputArray rvec,
                                  OutputArray tvec,
                                  bool useExtrinsicGuess = false,
                                  int iterationsCount = 100,
                                  float reprojectionError = 8.0,
                                  int minInliersCount = 100,
                                  OutputArray inliers = noArray(),
                                  int flags = ITERATIVE);

我将该句改为

cv::solvePnPRansac(p3d, p2d, K, cv::Mat(), R, t, false, 100, 8.0, 0, inliers,2);

重新编译运行。更换KITTI数据集试试看还会报错否

猜你喜欢

转载自blog.csdn.net/qq_36122936/article/details/88670659