HarborC / PL-SLAM

PL-SLAM: The method is implemented in《PL-SLAM:Real-time Monocular Visual SLAM with Points and Lines》
Other
220 stars 59 forks source link

发现潜在的bug #11

Open RayShark0605 opened 1 year ago

RayShark0605 commented 1 year ago

Tracking.cc [729行和738行附近] for (int i = 0; i < mInitialFrame.mvKeys.size(); i++) { int j = mvIniLastLineMatches[i]; if (j >= 0) { mvIniLastLineMatches[i] = mvIniLineMatches[j]; } } 这个循环中的变量i取决于mInitialFrame.mvKeys的大小,会导致mvIniLastLineMatches下标越界!!

LSDmatcher.cpp [944行附近] const float radius = th*pKF->mvScaleFactorsLine[nPredictedLevel]; 该语句中的中的nPredictedLevel可能会导致mvScaleFactorsLine下标越界!!在测试中发现,某个时候mvScaleFactorsLine是大小为1的vector,但是nPredictedLevel却为1(越界)

以上的bug会在Debug模式编译下运行报错!尽管在Release模式编译之后运行时并不会报错,但是可能会导致程序出现预料之外的结果! 请问,我该如何修改?

1 2

BambValley commented 1 year ago

这里可能是作者代码复现时,误把对线特征索引的遍历写成点特征的了。 我认为将 for (int i = 0; i < mInitialFrame.mvKeys.size(); i++) 改为: for (int i = 0; i < mInitialFrame.NL; i++) 或许会有帮助

BambValley commented 1 year ago

至于第二处越界错误 const float radius = th*pKF->mvScaleFactorsLine[nPredictedLevel];

我注意到项目中的配置文件Examples\Monocular\EuRoC.yaml的线特征层数设置为1: LINEextractor.nLevels: 1

这样匹配时所预测的特征所在层nPredictedLevel就没有意义了,因为只有一层, 你或许可以直接把nPredictedLevel置为0,即 nPredictedLevel = 0

为什么只有一层,我猜测是对于耗时的优化,LSD本身提取就比较耗时