文章目录
前言
高翔的《视觉slam14讲》ch5中的踩坑和解决方法
以及opencv在ubuntu22.04中的安装
一、opencv的安装
参考博客:
https://blog.csdn.net/public669/article/details/99044895
我选择的版本为3.4.2
跟着上面的博客应该没有大问题
二、imageBasics
1.imageBasics.cpp不做修改
2.CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(imageBasics)
set(CMAKE_CXX_STANDARD 14)
#寻找opencv库
find_package (OpenCV REQUIRED)
#添加头文件
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(imageBasics imageBasics.cpp)
# 链接OpenCV库
target_link_libraries(imageBasics ${OpenCV_LIBS})
报错:
‘decay_t’ is not a member of ‘std’
解决方法:
把set(CMAKE_CXX_FLAGS “-std=c++11 -O2”)换成set(CMAKE_CXX_STANDARD 14)
三.stereo
1. CMakeLists.txt
cmake_minimum_required( VERSION 2.8 )
project(stereoVision)
set(CMAKE_CXX_STANDARD 14)
include_directories("/usr/include/eigen3")
find_package(Pangolin REQUIRED)
include_directories( ${Pangolin_INCLUDE_DIRS} )
find_package(OpenCV)
include_directories(${OpenCV})
add_executable(stereoVision stereoVision.cpp)
target_link_libraries(stereoVision ${OpenCV_LIBS} ${Pangolin_LIBRARIES})
2.stereoVision.cpp
文件路径改成绝对路径
string left_file = "/home/ysl/slambook2/ch5/stereo/left.png";
string right_file = "/home/ysl/slambook2/ch5/stereo/right.png";
2.编译和运行
注意要在slambook2/ch5/stereo在个文件夹下
mkdir build && cd build
cmake ..
make
运行(要在build文件夹下运行):
./stereoVision
运行结果:
四、RGB-D视觉
参考博客成功运行:
https://blog.csdn.net/weixin_50578602/article/details/127343741
1、CMakeList.txt
修改CMakeList.txt如下:
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})
find_package( OpenCV 3.4.2 REQUIRED ) //这一步根据自己的版本来写
find_package(Pangolin REQUIRED)
add_executable(joinMap joinMap.cpp)
target_link_libraries(joinMap ${OpenCV_LIBS} ${Pangolin_LIBRARIES} ${Sophus_INCLUDE_DIRS} fmt)
2、路径修改
修改joinMap.cpp文件,修改21行为:
ifstream fin("../pose.txt");
修改28行(若行号不对请自行寻找)为:
boost::format fmt("../%s/%d.%s");
运行结果如下: