视觉SLAM十四讲——ch12实践(建图)
make -j” 是一个 Linux 命令,它使用所有可用的 CPU 核心来并行编译程序。通常在不指定进程数量时,使用这个命令可以最大化地利用 CPU 资源以加快编译速度。这个命令会启动尽可能多的进程来同时编译程序,以便快速生成可执行文件。此命令将自动检测计算机上可用的 CPU 核心数量,并在所有可用的核心上启动相应数目的编译任务。需要注意的是,由于多个进程同时在运行,因此使用 “make -j”
视觉SLAM十四讲——ch12的实践操作及避坑
0.实践前小知识介绍
“make -j” 是一个 Linux 命令,它使用所有可用的 CPU 核心来并行编译程序。通常在不指定进程数量时,使用这个命令可以最大化地利用 CPU 资源以加快编译速度。
这个命令会启动尽可能多的进程来同时编译程序,以便快速生成可执行文件。此命令将自动检测计算机上可用的 CPU 核心数量,并在所有可用的核心上启动相应数目的编译任务。
需要注意的是,由于多个进程同时在运行,因此使用 “make -j” 命令时可能会出现输出混乱的情况,但这不影响编译结果的正确性。如果您希望更清晰地查看编译过程,可以使用 “make VERBOSE=1” 命令,它会打印出更详细的编译信息。
“make -j8” 是一个 Linux 命令,意思是在编译时使用8个并行进程来加快编译速度。其中的 “-j” 参数表示并行进程数,后面的数字 “8” 表示使用 8 个进程来编译。
通过使用多个并行进程,可以同时处理多个编译任务,并且不会影响编译的正确性。这样可以大大提高编译的速度,在硬件条件允许的情况下,建议使用该参数来加快编译速度。
需要注意的是,并不是所有的编译任务都适合使用多进程并行编译,因此在使用该参数时,需要根据实际情况进行选择。同时也需要注意,如果硬件条件较差,使用过多的并行进程可能会导致编译失败或者系统卡死,因此需要根据自己的硬件条件来进行调整。
1. 实践操作前的准备工作
- 安装PCL
sudo apt-get install libpcl-dev pcl-tools
- 安装octomap
sudo apt-get install liboctomap-dev octovis
- 在终端中进入ch12文件夹下,顺序执行以下命令进行编译。
mkdir build
cd build
cmake ..
//注意,j8还是其他主要看自己的电脑情况
make -j8
-
在build文件中进行运行。
注意: 在make过程中,会出现warning,但是对我们此实践的过程几乎没有影响。 -
下载使用的测试数据,数据是提供了一架无人机采集的单目俯视图,一共200张,同时提供了每张图像的真是位姿。下载地址为http://rpg.ifi.uzh.ch/datasets/remode_test_data.zip
2. 实践过程
2.1 单目稠密重建
在build中执行语句:
cd dense_mono
./dense_mapping /home/fighter/slam/slambook2/ch12/test_data
运行结果:
第35次迭代图像:
//刚开始运行时的平均方差和平均误差:
*** loop 1 ***
Average squared error = 1.84285, average error: -1.12517
//迭代到199次时的平均方差和平均误差:
*** loop 199 ***
Average squared error = 0.253473, average error: -0.00722449
全部结果:
read total 202 files.
*** loop 1 ***
Average squared error = 1.84285, average error: -1.12517
*** loop 2 ***
Average squared error = 1.42146, average error: -0.865388
*** loop 3 ***
Average squared error = 1.05544, average error: -0.62268
*** loop 4 ***
Average squared error = 0.879682, average error: -0.515219
*** loop 5 ***
Average squared error = 0.45456, average error: -0.177368
*** loop 6 ***
Average squared error = 0.396917, average error: -0.128648
*** loop 7 ***
Average squared error = 0.364525, average error: -0.10006
*** loop 8 ***
Average squared error = 0.350139, average error: -0.0846462
*** loop 9 ***
Average squared error = 0.340283, average error: -0.0772052
*** loop 10 ***
Average squared error = 0.331579, average error: -0.0711182
*** loop 11 ***
Average squared error = 0.325072, average error: -0.0668865
*** loop 12 ***
Average squared error = 0.319159, average error: -0.0616389
*** loop 13 ***
Average squared error = 0.314988, average error: -0.0576225
*** loop 14 ***
Average squared error = 0.310317, average error: -0.0543781
*** loop 15 ***
Average squared error = 0.307007, average error: -0.0517102
*** loop 16 ***
Average squared error = 0.303809, average error: -0.0494418
*** loop 17 ***
Average squared error = 0.301495, average error: -0.0477168
*** loop 18 ***
Average squared error = 0.29937, average error: -0.0460656
*** loop 19 ***
Average squared error = 0.298098, average error: -0.0450206
*** loop 20 ***
Average squared error = 0.297042, average error: -0.0441051
*** loop 21 ***
Average squared error = 0.296148, average error: -0.0433046
*** loop 22 ***
Average squared error = 0.295283, average error: -0.0425197
*** loop 23 ***
Average squared error = 0.294497, average error: -0.0418231
*** loop 24 ***
Average squared error = 0.293742, average error: -0.0412219
*** loop 25 ***
Average squared error = 0.293078, average error: -0.0406908
*** loop 26 ***
Average squared error = 0.292565, average error: -0.0402601
*** loop 27 ***
Average squared error = 0.292155, average error: -0.0398929
*** loop 28 ***
Average squared error = 0.291749, average error: -0.0395666
*** loop 29 ***
Average squared error = 0.291299, average error: -0.0392129
*** loop 30 ***
Average squared error = 0.290664, average error: -0.0387602
*** loop 31 ***
Average squared error = 0.290207, average error: -0.0384231
*** loop 32 ***
Average squared error = 0.289564, average error: -0.037996
*** loop 33 ***
Average squared error = 0.289188, average error: -0.0377422
*** loop 34 ***
Average squared error = 0.288831, average error: -0.0373816
*** loop 35 ***
Average squared error = 0.288169, average error: -0.0369677
*** loop 36 ***
Average squared error = 0.28776, average error: -0.0366579
*** loop 37 ***
Average squared error = 0.287351, average error: -0.0363873
*** loop 38 ***
Average squared error = 0.286934, average error: -0.0361053
*** loop 39 ***
Average squared error = 0.286412, average error: -0.0357436
*** loop 40 ***
Average squared error = 0.286034, average error: -0.0354667
*** loop 41 ***
Average squared error = 0.285515, average error: -0.0351335
*** loop 42 ***
Average squared error = 0.285065, average error: -0.0347901
*** loop 43 ***
Average squared error = 0.284475, average error: -0.0343606
*** loop 44 ***
Average squared error = 0.28398, average error: -0.0339507
*** loop 45 ***
Average squared error = 0.283484, average error: -0.0335147
*** loop 46 ***
Average squared error = 0.282962, average error: -0.0330494
*** loop 47 ***
Average squared error = 0.282207, average error: -0.0324265
*** loop 48 ***
Average squared error = 0.281722, average error: -0.0319793
*** loop 49 ***
Average squared error = 0.28126, average error: -0.0314694
*** loop 50 ***
Average squared error = 0.280613, average error: -0.0308945
*** loop 51 ***
Average squared error = 0.28026, average error: -0.0304981
*** loop 52 ***
Average squared error = 0.279828, average error: -0.0301664
*** loop 53 ***
Average squared error = 0.279481, average error: -0.0299141
*** loop 54 ***
Average squared error = 0.279225, average error: -0.0297781
*** loop 55 ***
Average squared error = 0.279093, average error: -0.0296969
*** loop 56 ***
Average squared error = 0.27885, average error: -0.029586
*** loop 57 ***
Average squared error = 0.278791, average error: -0.0295429
*** loop 58 ***
Average squared error = 0.278614, average error: -0.029461
*** loop 59 ***
Average squared error = 0.278394, average error: -0.0293721
*** loop 60 ***
Average squared error = 0.278216, average error: -0.0292924
*** loop 61 ***
Average squared error = 0.27807, average error: -0.0292331
*** loop 62 ***
Average squared error = 0.277898, average error: -0.0291653
*** loop 63 ***
Average squared error = 0.277636, average error: -0.0290668
*** loop 64 ***
Average squared error = 0.27748, average error: -0.0290064
*** loop 65 ***
Average squared error = 0.277295, average error: -0.0289306
*** loop 66 ***
Average squared error = 0.277196, average error: -0.0288857
*** loop 67 ***
Average squared error = 0.277002, average error: -0.0288019
*** loop 68 ***
Average squared error = 0.276856, average error: -0.0287178
*** loop 69 ***
Average squared error = 0.276715, average error: -0.028626
*** loop 70 ***
Average squared error = 0.276542, average error: -0.0285359
*** loop 71 ***
Average squared error = 0.27639, average error: -0.0284511
*** loop 72 ***
Average squared error = 0.276233, average error: -0.0283693
*** loop 73 ***
Average squared error = 0.276015, average error: -0.0282531
*** loop 74 ***
Average squared error = 0.275862, average error: -0.0281722
*** loop 75 ***
Average squared error = 0.275723, average error: -0.0280873
*** loop 76 ***
Average squared error = 0.275545, average error: -0.027981
*** loop 77 ***
Average squared error = 0.275377, average error: -0.0278906
*** loop 78 ***
Average squared error = 0.275231, average error: -0.0278025
*** loop 79 ***
Average squared error = 0.275086, average error: -0.0277176
*** loop 80 ***
Average squared error = 0.274987, average error: -0.0276476
*** loop 81 ***
Average squared error = 0.274899, average error: -0.0275886
*** loop 82 ***
Average squared error = 0.274696, average error: -0.0274517
*** loop 83 ***
Average squared error = 0.274517, average error: -0.0272981
*** loop 84 ***
Average squared error = 0.274293, average error: -0.0271339
*** loop 85 ***
Average squared error = 0.274005, average error: -0.0268708
*** loop 86 ***
Average squared error = 0.273686, average error: -0.0265032
*** loop 87 ***
Average squared error = 0.273051, average error: -0.0257165
*** loop 88 ***
Average squared error = 0.272044, average error: -0.0243797
*** loop 89 ***
Average squared error = 0.271037, average error: -0.0231086
*** loop 90 ***
Average squared error = 0.270173, average error: -0.0222034
*** loop 91 ***
Average squared error = 0.268837, average error: -0.0205596
*** loop 92 ***
Average squared error = 0.268364, average error: -0.0192558
*** loop 93 ***
Average squared error = 0.267513, average error: -0.0182724
*** loop 94 ***
Average squared error = 0.266708, average error: -0.0175116
*** loop 95 ***
Average squared error = 0.2659, average error: -0.0167705
*** loop 96 ***
Average squared error = 0.265119, average error: -0.0160555
*** loop 97 ***
Average squared error = 0.264688, average error: -0.0156661
*** loop 98 ***
Average squared error = 0.264175, average error: -0.0152503
*** loop 99 ***
Average squared error = 0.263741, average error: -0.0148952
*** loop 100 ***
Average squared error = 0.263298, average error: -0.0145078
*** loop 101 ***
Average squared error = 0.26283, average error: -0.0139689
*** loop 102 ***
Average squared error = 0.262504, average error: -0.0136983
*** loop 103 ***
Average squared error = 0.261961, average error: -0.0132759
*** loop 104 ***
Average squared error = 0.261467, average error: -0.0128025
*** loop 105 ***
Average squared error = 0.261184, average error: -0.0125387
*** loop 106 ***
Average squared error = 0.260951, average error: -0.0123502
*** loop 107 ***
*** loop 108 ***
Average squared error = 0.260779, average error: -0.0122728
*** loop 109 ***
Average squared error = 0.260547, average error: -0.0121443
*** loop 110 ***
Average squared error = 0.260369, average error: -0.0120564
*** loop 111 ***
Average squared error = 0.260171, average error: -0.0119496
*** loop 112 ***
Average squared error = 0.25991, average error: -0.0118314
*** loop 113 ***
Average squared error = 0.259633, average error: -0.0117062
*** loop 114 ***
Average squared error = 0.259358, average error: -0.0115578
*** loop 115 ***
Average squared error = 0.259097, average error: -0.0114197
*** loop 116 ***
Average squared error = 0.258921, average error: -0.0113019
*** loop 117 ***
Average squared error = 0.258636, average error: -0.0111453
*** loop 118 ***
Average squared error = 0.258323, average error: -0.0109411
*** loop 119 ***
Average squared error = 0.258012, average error: -0.010738
*** loop 120 ***
Average squared error = 0.25748, average error: -0.0103609
*** loop 121 ***
Average squared error = 0.256995, average error: -0.0100245
*** loop 122 ***
Average squared error = 0.256586, average error: -0.00968946
*** loop 123 ***
Average squared error = 0.256245, average error: -0.00937251
*** loop 124 ***
Average squared error = 0.255877, average error: -0.00895965
*** loop 125 ***
Average squared error = 0.255615, average error: -0.00863918
*** loop 126 ***
Average squared error = 0.255493, average error: -0.00842778
*** loop 127 ***
Average squared error = 0.255422, average error: -0.00832814
*** loop 128 ***
Average squared error = 0.255371, average error: -0.00828552
*** loop 129 ***
Average squared error = 0.255334, average error: -0.00825662
*** loop 130 ***
Average squared error = 0.255342, average error: -0.0082551
*** loop 131 ***
Average squared error = 0.25535, average error: -0.00825099
*** loop 132 ***
Average squared error = 0.25532, average error: -0.0082309
*** loop 133 ***
Average squared error = 0.255291, average error: -0.00821913
*** loop 134 ***
Average squared error = 0.255274, average error: -0.0082109
*** loop 135 ***
Average squared error = 0.255271, average error: -0.00820692
*** loop 136 ***
Average squared error = 0.255272, average error: -0.00819507
*** loop 137 ***
Average squared error = 0.255216, average error: -0.00817473
*** loop 138 ***
Average squared error = 0.255177, average error: -0.00815629
*** loop 139 ***
Average squared error = 0.255138, average error: -0.00814459
*** loop 140 ***
Average squared error = 0.255086, average error: -0.00812726
*** loop 141 ***
Average squared error = 0.25507, average error: -0.00812055
*** loop 142 ***
Average squared error = 0.254982, average error: -0.00808992
*** loop 143 ***
Average squared error = 0.25494, average error: -0.00807278
*** loop 144 ***
Average squared error = 0.254944, average error: -0.00807379
*** loop 145 ***
Average squared error = 0.254885, average error: -0.0080535
*** loop 146 ***
Average squared error = 0.254837, average error: -0.00803103
*** loop 147 ***
Average squared error = 0.254814, average error: -0.00799901
*** loop 148 ***
Average squared error = 0.254806, average error: -0.00799629
*** loop 149 ***
Average squared error = 0.2548, average error: -0.0079941
*** loop 150 ***
Average squared error = 0.254776, average error: -0.00797947
*** loop 151 ***
Average squared error = 0.254771, average error: -0.00797405
*** loop 152 ***
Average squared error = 0.254746, average error: -0.0079654
*** loop 153 ***
Average squared error = 0.254724, average error: -0.00795639
*** loop 154 ***
Average squared error = 0.254699, average error: -0.0079408
*** loop 155 ***
Average squared error = 0.254636, average error: -0.0079139
*** loop 156 ***
Average squared error = 0.254568, average error: -0.00787785
*** loop 157 ***
Average squared error = 0.254525, average error: -0.00784813
*** loop 158 ***
Average squared error = 0.254369, average error: -0.00776553
*** loop 159 ***
Average squared error = 0.254215, average error: -0.0076815
*** loop 160 ***
Average squared error = 0.254138, average error: -0.00763075
*** loop 161 ***
Average squared error = 0.254019, average error: -0.00756259
*** loop 162 ***
Average squared error = 0.253929, average error: -0.00751232
*** loop 163 ***
Average squared error = 0.253854, average error: -0.00746892
*** loop 164 ***
Average squared error = 0.253793, average error: -0.00743709
*** loop 165 ***
Average squared error = 0.253723, average error: -0.00739672
*** loop 166 ***
Average squared error = 0.253581, average error: -0.00732856
*** loop 167 ***
Average squared error = 0.253574, average error: -0.00732363
*** loop 168 ***
Average squared error = 0.253507, average error: -0.00729212
*** loop 169 ***
Average squared error = 0.253487, average error: -0.00728301
*** loop 170 ***
Average squared error = 0.253473, average error: -0.0072775
*** loop 171 ***
Average squared error = 0.253474, average error: -0.00726942
*** loop 172 ***
Average squared error = 0.25347, average error: -0.00727054
*** loop 173 ***
Average squared error = 0.253469, average error: -0.00726697
*** loop 174 ***
Average squared error = 0.253457, average error: -0.00726471
*** loop 175 ***
Average squared error = 0.253392, average error: -0.00723937
*** loop 176 ***
Average squared error = 0.253359, average error: -0.00722755
*** loop 177 ***
Average squared error = 0.25335, average error: -0.00722365
*** loop 178 ***
Average squared error = 0.253339, average error: -0.00721831
*** loop 179 ***
Average squared error = 0.253538, average error: -0.00723501
*** loop 180 ***
Average squared error = 0.253541, average error: -0.0072366
*** loop 181 ***
Average squared error = 0.253536, average error: -0.0072361
*** loop 182 ***
Average squared error = 0.253528, average error: -0.00723492
*** loop 183 ***
Average squared error = 0.253508, average error: -0.00723009
*** loop 184 ***
Average squared error = 0.253493, average error: -0.00722341
*** loop 185 ***
Average squared error = 0.253485, average error: -0.00722269
*** loop 186 ***
Average squared error = 0.253462, average error: -0.00721511
*** loop 187 ***
Average squared error = 0.253452, average error: -0.00721043
*** loop 188 ***
Average squared error = 0.253456, average error: -0.00721228
*** loop 189 ***
Average squared error = 0.253466, average error: -0.00721536
*** loop 190 ***
Average squared error = 0.253458, average error: -0.00721122
*** loop 191 ***
Average squared error = 0.253469, average error: -0.00721441
*** loop 192 ***
Average squared error = 0.253477, average error: -0.00721751
*** loop 193 ***
Average squared error = 0.253482, average error: -0.00722042
*** loop 194 ***
Average squared error = 0.253482, average error: -0.00722156
*** loop 195 ***
Average squared error = 0.253482, average error: -0.00722296
*** loop 196 ***
Average squared error = 0.253481, average error: -0.00722378
*** loop 197 ***
Average squared error = 0.25348, average error: -0.00722574
*** loop 198 ***
Average squared error = 0.253476, average error: -0.00722573
*** loop 199 ***
Average squared error = 0.253473, average error: -0.00722449
可以看出前10次效果显著,10次时候速度下降。
2.2 RGB-D稠密建图
-
RGB-D稠密建图是一种利用RGB图像和深度图像进行三维重建的技术。与传统的基于三角化的稀疏重建方法不同,RGB-D稠密建图可以生成全局一致的稠密三维模型,包括物体的细节和形状。该技术已广泛应用于机器人导航、虚拟现实、增强现实和医疗领域等。
-
RGB-D稠密建图的基本流程包括:采集RGB和深度图像、点云生成、稠密重建和纹理映射。其中,点云生成是将RGB图像和深度图像转换为三维点云数据,稠密重建是将点云数据转换为三维模型,纹理映射则是将RGB图像映射到三维模型表面,使得模型具有真实感和逼真度。
-
RGB-D稠密建图的优点是可以快速地生成高质量的三维模型,并且可以捕捉物体的表面细节和形态信息。不过,由于对图像质量和标定精度要求较高,该技术在实际应用中还需要进一步的改进和完善。
2.3 点云地图
在build中执行语句:
cd dense_RGBD
./pointcloud_mapping
运行结果:
正在将图像转换为点云...
转换图像中: 1
转换图像中: 2
转换图像中: 3
转换图像中: 4
转换图像中: 5
点云共有1309800个点.
滤波之后,点云共有31876个点.
同时生成一个map.pcd文件,此文件的位置在:
/home/fighter/slam/slambook2/ch12/build/dense_RGBD/ map.pcd
可以用通过以下命令来查看map.pcd文件:
pcl_viewer map.pcd
体素滤波之后的点云,可以看到运行结果如下,这是ICL-NUIM五张图像重建的结果:
滚轮放大后查看:
滚论滑动变小后查看:
同时,终端也会输出对应信息:
The viewer window provides interactive commands; for help, press 'h' or 'H' from within the window.
> Loading map.pcd [PCLVisualizer::setUseVbos] Has no effect when OpenGL version is ≥ 2
[done, 378.775 ms : 31876 points]
Available dimensions: x y z rgb
2.4 从点云重建网格
在build中执行语句:
cd dense_RGBD
./surfel_mapping map.pcd
运行结果:
结果时从点云重建得到的表面和网格模型,图像如下
同时终端输出信息:
point cloud loaded, points: 31876
computing normals ...
computing mesh ...
display mesh ...
2.5 八叉树地图
在build中执行语句:
cd dense_RGBD
./octomap_mapping
运行结果:
终端输出:
正在将图像转换为 Octomap ...
转换图像中: 1
转换图像中: 2
转换图像中: 3
转换图像中: 4
转换图像中: 5
saving octomap ...
Writing 1136665 nodes to output stream... done.
运行生成文件octomap.bt,使用以下命令来查看文件:
octovis octomap.bt
终端输出:
Reading binary octree type OcTree
八叉树地图在不同分辨率的图像如下所示
3. 遇到的问题及解决办法
3.1 cmake …时,出现opencv版本问题
出现的错误:
CMake Error at dense_mono/CMakeLists.txt:11 (find_package):
Could not find a configuration file for package "OpenCV" that is compatible
with requested version "3.1".
The following configuration files were considered but not accepted:
/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.0
/usr/lib/x86_64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake, version: 4.2.0
/lib/x86_64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake, version: 4.2.0
原因:
CMakeLists.txt中,设置的opencv的版本有问题;
出现此种问题主要是代码中的opencv的版本和自己当前安装的版本不同。
解决办法:
直接和之前的解决办法一样,更改CMakeLists.txt文件中的opencv版本即可。
//更改前:
find_package(OpenCV 3 REQUIRED)
//更改后:
find_package(OpenCV REQUIRED)
3.2 make -j8时,出现一些错误,有关PCL和opencv版本的问题。
- 出现的问题:
未定义标识符 “CV_GRAY2BGR”
原因:
这是因为此语句和opencv版本不相同。
解决办法:
更改dense_mapping.cpp头文件,添加以下头文件:
//添加头文件
#include <opencv2/imgproc/types_c.h>
有关opencv版本和语句问题的报错的锦集可以参考文章:https://blog.csdn.net/qq_44164791/article/details/131210608?spm=1001.2014.3001.5502
- 出现的问题:
出现的问题:
在make时,出现了刷屏的红色错误,这里展示两段:
/usr/include/pcl-1.10/pcl/pcl_config.h:7:4: error: #error PCL requires C++14 or above
7 | #error PCL requires C++14 or above
| ^~~~~
In file included from /usr/include/pcl-1.10/pcl/pcl_macros.h:77,
from /usr/include/pcl-1.10/pcl/point_types.h:42,
from /home/fighter/slam/slambook2/ch12/dense_RGBD/pointcloud_mapping.cpp:10:
/usr/include/pcl-1.10/pcl/pcl_config.h:7:4: error: #error PCL requires C++14 or above
7 | #error PCL requires C++14 or above
| ^~~~~
In file included from /usr/include/pcl-1.10/pcl/console/print.h:44,
from /usr/include/pcl-1.10/pcl/conversions.h:53,
from /usr/include/pcl-1.10/pcl/common/io.h:48,
from /usr/include/pcl-1.10/pcl/io/file_io.h:41,
from /usr/include/pcl-1.10/pcl/io/pcd_io.h:44,
from /home/fighter/slam/slambook2/ch12/dense_RGBD/surfel_mapping.cpp:7:
/usr/include/pcl-1.10/pcl/pcl_config.h:7:4: error: #error PCL requires C++14 or above
7 | #error PCL requires C++14 or above
| ^~~~~
In file included from /usr/include/pcl-1.10/pcl/console/print.h:44,
from /usr/include/pcl-1.10/pcl/conversions.h:53,
from /usr/include/pcl-1.10/pcl/common/io.h:48,
from /usr/include/pcl-1.10/pcl/io/file_io.h:41,
from /usr/include/pcl-1.10/pcl/io/pcd_io.h:44,
from /home/fighter/slam/slambook2/ch12/dense_RGBD/pointcloud_mapping.cpp:11:
/usr/include/pcl-1.10/pcl/pcl_config.h:7:4: error: #error PCL requires C++14 or above
7 | #error PCL requires C++14 or above
| ^~~~~
原因:
最主要的原因时因为C++版本的问题
解决办法:
将含有C++版本设置语句的CMakeLists.txt文件中有关其版本,全部改为14以上。
然后,make时会出现部分警告,当时不影响程序结果。
3.3 cmake …时,会出现vtk的问题,
出现的问题:
The imported target "vtkRenderingPythonTkWidgets" references the file
"/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
but not all the files it references.
-- The imported target "pvtk" references the file
"/usr/bin/pvtk"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
but not all the files it references.
解决办法:
创建两个软链接:
第一个软链接:
sudo ln -s /usr/lib/python2.7/dist-packages/vtk/libvtkRenderingPythonTkWidgets.x86_64-linux-gnu.so /usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so
第二个软链接:
sudo ln -s /usr/bin/vtk7 /usr/bin/vtk
3.4 运行 ./dense_mapping /home/fighter/slam/slambook2/ch12/test_data时,出现段错误
出现的错误:
./dense_mapping /home/fighter/slam/slambook2/ch12/test_data
read total 202 files.
*** loop 1 ***
Segmentation fault
原因:
Segmentation fault (core dumped)多为内存不当操作造成。空指针、野指针的读写操作,数组越界访问,破坏常量等。如最近的势能图代码中的链表操作,对链表的新增和释放包括赋值等等,如出现不当操作都有可能造成程序崩溃。对每个指针声明后进行初始化为NULL是避免这个问题的好办法。排除此问题的最好办法则是调试。
解决办法:
将文件dense_mapping.cpp中update函数为定义为bool类型,但是没有返回值,可以改为void。
更改前,例其中一处:
更改后,例其中一处:
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)