拖了好久才写。。。懒!!!
第五篇就是将第四篇的一些功能整合成函数,然后由两帧扩展成700帧。
先从parameter.txt说起:
# part 5
# 数据相关
# 起始与终止索引
start_index=1
end_index=700
# 数据所在目录
rgb_dir=../inputdata/rgb_png/
rgb_extension=.png
depth_dir=../inputdata/depth_png/
depth_extension=.png
# 点云分辨率
voxel_grid=0.02
# 是否实时可视化
visualize_pointcloud=yes
# 最小匹配数量
min_good_match=10
# 最小内点
min_inliers=5
# 最大运动误差
max_norm=0.3
上面是参数文件中增加的部分。包含循环读取帧所需的路径和扩展名,还有在两帧匹配后,对匹配进行筛选的设定。
再看src/CmakeLists.txt
# 由于需要链接boost库,所以需要find_package和include_directries进 boost库
find_package(Boost REQUIRED COMPONENTS system)
include_directories(${Boost_INCLUDE_DIRS})
# 增加opencv库依赖
FIND_PACKAGE( OpenCV REQUIRED )
INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} )
# 增加PCL库依赖
FIND_PACKAGE( PCL REQUIRED COMPONENTS common io visualization)
list(REMOVE_ITEM PCL_LIBRARIES "vtkproj4")
INCLUDE_DIRECTORIES( ${PCL_INCLUDE_DIRS} )
ADD_DEFINITIONS( ${PCL_DEFINITIONS} )
LINK_LIBRARIES( ${PCL_LIBRARY_DIRS} )
# 增加库文件slamBase
add_library(slambase slamBase.cpp)
target_link_libraries(slambase
${OpenCV_LIBS}
${PCL_LIBS})
#[[
# 增加generate_pointcloud可执行程序,并将其链接到依赖库上
ADD_EXECUTABLE( generate_pointcloud generatePointCloud.cpp )
TARGET_LINK_LIBRARIES( generate_pointcloud
${OpenCV_LIBS}
${PCL_LIBRARIES} )
# 增加特征点匹配的可执行文件
add_executable(detectfeacures detectFeacures.cpp )
# 这里也是将boost库链接进来
target_link_libraries(detectfeacures ${Boost_LIBRARIES} slambase )
#增加合并点云可执行文件
ADD_EXECUTABLE( joinPointCloud joinPointCloud.cpp)
TARGET_LINK_LIBRARIES( joinPointCloud
slambase
${OpenCV_LIBS}
${PCL_LIBRARIES}
${pcl_visualization_libraries} )]]
# #[[...]]整体注释
add_executable(visualOdometry visualOdometry.cpp)
target_link_libraries(visualOdometry
slambase
${OpenCV_LIBS}