[Reading notes] "visual SLAM fourteen speak (with Gao Xiang)," Lecture 5

Here Insert Picture Description

PART1 study notes

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

PART2 practical part

  • Practice 5.3: access and accessing the document image P95
    5.3.1 OpenCV installed
    according to the installation procedure book.
    5.3.2 Operation OpenCV image
    here p96 book pages according to tells substantially example code:
    2 lines: counting procedure related;
    56 OK: Related OpenCV;
    10-18 line: and determines whether the read image read correctly;
    line 21: width and height of the channel number information of the output image;
    line 22: displaying an image;
    line 23: paused program, press against the open image (optional) keyboard, the program will execute the next step;
    25-30 line: determining an image type compliance;
    32-52 lines: traversing the image pixels, and outputs the time it takes;
    54-60 line: copy the picture (the wrong way), directly to the original assigned to the new plan, then, if the change in the new map, the original Figure will also change; 60 lines with 23 rows;
    62-67 line: correct image copy method to change the view after the new copy, the original image remains unchanged. 67 lines with 60 lines;
    Line 70: So close open picture window;
  • 5.4实践:拼接点云
    一、Ubuntu下的PCL库安装
    安装记录(20190611YC):
    ①先按照书P99下方的三行代码安装,结果出现错误:E: 无法定位软件包 libpcl-all
    ②之后按照网页https://blog.csdn.net/dantengc/article/details/78446600中的方法3安装,也即“源代码安装”,安装时间很长,大概3-4个小时,且并未安装好,PCL安装的不完整不能正常使用。采用源代码安装的PCL在调用的时候出现错误:fatal error: pcl/visualization/pcl_visualizer.h: No such file or directory,原因是在编译和安装时没有在urs/include/plcX.X目录下生成pcl_visualizer.h。按照网页https://blog.csdn.net/unlimitedai/article/details/86481912的方法去解决该问题,并未成功。至此,源代码安装方法失败。
    ③最终将PCL安装成功,是采用网页https://blog.csdn.net/fanjiule/article/details/80913894的方法,具体如下:
    电脑退出校园网,连上手机热点网络;
    使用命令:
    sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
    sudo apt-get update
    sudo apt-get install libpcl-dev
    注意,第3行命令和书P99下方的命令不同。
    如此即可成功安装PCL:
    Here Insert Picture Description
    Here Insert Picture Description

④PCL安装好之后,调试程序若仍出问题,可仔细检查CMakeLists.txt文件中的语句,或弃用其中的find_package函数,而直接输入PCL在本电脑的安装路径。当前CMakeLists.txt已调试通过,可供后续参考:

cmake_minimum_required(VERSION 2.6)
project(show_sample)#改1处

find_package( PCL REQUIRED COMPONENTS common io visualization )#20190611YC:若无这一行,则出现报错:对‘pcl::visualization::CloudViewer::CloudViewer(std::__cxx11::basic_string<

find_package( PCL 1.7 REQUIRED COMPONENT common io )
include_directories( “/usr/include/pcl-1.7/” )
link_directories("/usr/lib/libpcl_common.so" “/usr/lib/libpcl_io.so”)
list (REMOVE_ITEM PCL_LIBRARIES “vtkproj4”)

add_executable(show_sample show_sample.cpp)#改2处

target_link_libraries (show_sample ${PCL_LIBRARIES})#改1处

install(TARGETS show_sample RUNTIME DESTINATION bin)#改1处

二、程序说明
【注意!】该例程在编译的时候,不要再mkdir build; cd build,而是直接在当前目录下cmake.,不然运行会出错!
根据书P100页,大致分析本例程:
14行:定义变量,分别用于存储彩色图和深度图;
15:定义变量,用于存储相机位姿;
17-22:检查位姿数据(pose.txt)是否在当前目录下,要求该文件在当前目录下,不然就会有报错提示。
26-28:5张图片的色彩图像和深度图像的读取,并存储在变量中;
30-37:5张图片对应的5个位姿信息从pose.txt转化为变换矩阵T,并存储在变量中;
39-45:相机内参赋值;
47-50:定义类型:点和点云文件;
53:新建一个点云;
54-80:依次对5张图片执行以下操作:利用上述变量中的色彩、深度、位姿信息,计算出每张图片的每个像素点在世界坐标系下的坐标,结合像素点自身的颜色,作为点云文件中的一个点。最终得出5张图片所有像素点在世界坐标系下的坐标和颜色都求了出来,形成彩色点云。
57:赋值:每张图片的色彩信息;
58:赋值:每张图片的深度信息;
59:赋值:每张图片的位姿信息;
60-61:对于每张图片,遍历本图片的所有像素点;
63:赋值:每个像素点的深度信息;
64:如果深度信息不是0;
65:定义变量,表示一个三位点坐标;
66-68:根据像素坐标和相机内参,反算出点在相机坐标系下的坐标;
69: According to the present posture information of the image, the coordinates of the camera coordinate system into coordinates in the world coordinate system;
71: definition of a point p, the point p is the point cloud data points are 1;
72, 73, 74: the three-dimensional coordinates of the calculated values of the world coordinate system is assigned to the point p;
, 76, 77: assign to a point p rgb color information;
78: the new point p inclusion into the cloud point variable line 53;
82: is_dense (bool): determines whether the data points is limited (limited to true) is to determine the point or cloud point is contained Inf / NaN such values (including to false). Contents of this area For more refer to the website:
https://blog.csdn.net/Linear_Luo/article/details/52647790
84: The new 53-line, 78-line through the point cloud variable assignment pointCloud save point cloud file map.pcd

Guess you like

Origin blog.csdn.net/dahailuoa6/article/details/90896261