slambook2(ch5)—— Ubuntu18.04安装openCV3.2.0库 + 修改报错 + 例程演示
一、安装依赖项
1.按照书上的依赖项安装
sudo apt-get install build-essential libgtk2.0-dev libvtk5-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev libtbb-dev
1.1报错:没有可用的软件包
没有可用的软件包 libtiff4-dev,但是它被其它的软件包引用了。
这可能意味着这个缺失的软件包可能已被废弃,
或者只能在其他发布源中找到
然而下列软件包会取代它:
libtiff5-dev:i386 libtiff5-dev
没有可用的软件包 libvtk5-dev,但是它被其它的软件包引用了。
这可能意味着这个缺失的软件包可能已被废弃,
或者只能在其他发布源中找到
然而下列软件包会取代它:
libvtk7-dev:i386 libvtk6-dev:i386 libvtk7-dev libvtk6-dev
E: 软件包 libvtk5-dev 没有可安装候选
E: 软件包 libtiff4-dev 没有可安装候选
E: 无法定位软件包 libjasper-dev
1.2报错无法定位软件包libjasper-dev的解决办法
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt upgrade
sudo apt install libjasper1 libjasper-dev
其中libjasper1是libjasper-dev的依赖包
2.装的新版本libvtk6-dev、libtiff5-dev重新安装
sudo apt-get install build-essential libgtk2.0-dev libvtk6-dev libjpeg-dev libtiff5-dev libopenexr-dev libtbb-dev
//记录版本
build-essential 已经是最新版 (12.4ubuntu1)。
libjpeg-dev 已经是最新版 (8c-2ubuntu8)。
libopenexr-dev 已经是最新版 (2.2.0-11.1ubuntu1.9)。
libtiff5-dev 已经是最新版 (4.0.9-5ubuntu0.4)。
2.1报错:有几个软件包无法下载
E: 无法下载 http://cn.archive.ubuntu.com/ubuntu/pool/main/t/tcl8.6/tcl8.6_8.6.8+dfsg-3_amd64.deb Hash 校验和不符
E: 无法下载 http://cn.archive.ubuntu.com/ubuntu/pool/universe/t/tcltk-defaults/tk_8.6.0+9_amd64.deb Hash 校验和不符
Hashes of expected file:
- SHA256:a158d36580f6d66ee5765ee83a2e8721de9dfc3ee5159cc98d8796a096e45940
- SHA1:485767720808e8a66193e15eca22d0d177d49081 [weak]
- MD5Sum:ac9c7f59c64d2e6574230de468c955cd [weak]
- Filesize:3178 [weak]
Hashes of received file:
- SHA256:bc8c6506501b2e2c9ddfac6691a34c12fbf19c0c1f313e8bddf0d0c9f35bf0c5
- SHA1:1ab8d584033663265c1ddd9d3368efd4f81aab79 [weak]
- MD5Sum:5019ba04272f203459eeb2a0fd4475d3 [weak]
- Filesize:3178 [weak]
Last modification reported: Fri, 20 Nov 2015 17:20:42 +0000
E: 有几个软件包无法下载,要不运行 apt-get update 或者加上 --fix-missing 的选项再试试?
2.1.1处理方式一:
更新软件包管理器
sudo apt-get update
sudo apt-get install xxxx --fix-missing
继续报错:文件尺寸不符(545256 != 193888)。您使用的镜像正在同步中?
执行这两句之后,再尝试安装自己需要的软件。
获取:1 http://202.199.28.1/files/A0560000010FF685/mirrors.ustc.edu.cn/raspbian/raspbian bionic/main amd64 libtool all 2.4.6-2 [194 kB]
忽略:1 http://202.199.28.1/files/A0560000010FF685/mirrors.ustc.edu.cn/raspbian/raspbian bionic/main amd64 libtool all 2.4.6-2
错误:1 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libtool all 2.4.6-2
文件尺寸不符(545256 != 193888)。您使用的镜像正在同步中? [IP: 202.199.28.1 80]
E: 无法下载 http://cn.archive.ubuntu.com/ubuntu/pool/main/libt/libtool/libtool_2.4.6-2_all.deb 文件尺寸不符(545256 != 193888)。您使用的镜像正在同步中? [IP: 202.199.28.1 80]
E: 有几个软件包无法下载,要不运行 apt-get update 或者加上 --fix-missing 的选项再试试?
问题分析:
报错是因为需要安装某个依赖库,但是在安装过程中找不到该依赖,原因位置。可尝试解决方法:
2.1.2处理方式二:
更换阿里源代理
问题修复
1)备份源文件:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2)查看版本信息
如是Linux Mint等Ubuntu衍生版,执行:
cat /etc/upstream-release/lsb-release
如是Ubuntu直接执行:
lsb_release -c
确认当前系统代号(Codename)为:bionic
。如是其他版本,请使用其他版本的软件源,其中:
Ubuntu 12.04 (LTS)代号为precise。
Ubuntu 14.04 (LTS)代号为trusty。
Ubuntu 15.04 代号为vivid。
Ubuntu 15.10 代号为wily。
Ubuntu 16.04 (LTS)代号为xenial。
3)修改sources.list:
修改/etc/apt/sources.list
为以下内容:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
4)检查更新
sudo apt-get update
5)重新安装软件
sudo apt-get install XXX
换阿里源后还是不行,继续换源!!!、
2.1.3处理方式三:
继续换源:选择最佳服务器
安装成功!!!!!
二、安装Opecv3.2.0
1.下载opecv包,并提取到某位置,进行安装
下载路径:https://codeload.github.com/opencv/opencv/zip/3.2.0
然后进入解压后的文件夹,在终端打开
接下来在命令行输入:
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3 ..
make -j4
sudo make install
值得注意的是,cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3 …
这里一定要指定安装路径,注意这里与官网不一样!按照我的来
1.1报错:-- ICV: Downloading ippicv_linux_20151201.tgz...
-- ICV: Downloading ippicv_linux_20151201.tgz...
CMake Error at 3rdparty/ippicv/downloader.cmake:73 (file):
file DOWNLOAD HASH mismatch
for file: [/home/sfann/sf_slam_temp_code/ch2/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz]
expected hash: [808b791a6eac9ed78d32a7666804320e]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [7;"Couldn't connect to server"]
原因及解决办法:
包ippicv下载过慢,则中断安装后,自己下载:
https://github.com/opencv/opencv_3rdparty/blob/ippicv/master_20151201/ippicv/ippicv_linux_20151201.tgz
如下载不了,是因为其服务器在国外我下载在阿里网盘中可以下载:https://www.aliyundrive.com/s/WzBfKzMLJ5k
然后将下载下来的ippicv_linux_20151201.tgz
放入opencv3
(让你指定的下载路径嘛)下面的:3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e
里即可。
命令行输入:
cp ippicv_linux_20151201.tgz* -rf /home/sfann/sf_slam_temp_code/ch2/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e
1.2报错: fatal error: stdlib.h
: 没有那个文件或目录
报错:fatal error: stdlib.h
: 没有那个文件或目录
[ 21%] Generating precomp.hpp.gch/opencv_viz_Release.gch
In file included from /usr/include/c++/7/ext/string_conversions.h:41:0,
from /usr/include/c++/7/bits/basic_string.h:6361,
from /usr/include/c++/7/string:52,
from /usr/include/c++/7/stdexcept:39,
from /usr/include/c++/7/array:39,
from /usr/include/c++/7/tuple:39,
from /usr/include/c++/7/bits/stl_map.h:63,
from /usr/include/c++/7/map:61,
from /home/sfann/sf_slam_temp_code/ch2/opencv-3.2.0/build/modules/viz/precomp.hpp:49:
/usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: 没有那个文件或目录
#include_next <stdlib.h>
^~~~~~~~~~
compilation terminated.
modules/viz/CMakeFiles/pch_Generate_opencv_viz.dir/build.make:81: recipe for target 'modules/viz/precomp.hpp.gch/opencv_viz_Release.gch' failed
make[2]: *** [modules/viz/precomp.hpp.gch/opencv_viz_Release.gch] Error 1
CMakeFiles/Makefile2:3186: recipe for target 'modules/viz/CMakeFiles/pch_Generate_opencv_viz.dir/all' failed
make[1]: *** [modules/viz/CMakeFiles/pch_Generate_opencv_viz.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
[ 21%] Built target pch_Generate_opencv_video
[ 21%] Built target pch_Generate_opencv_test_video
[ 21%] Built target pch_Generate_opencv_perf_video
Makefile:181: recipe for target 'all' failed
make: *** [all] Error 2
解决办法:
则cmake预编译修改为:
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3 -D ENABLE_PRECOMPILED_HEADERS=OFF ..
主要是加了一个参数:-D ENABLE_PRECOMPILED_HEADERS=OFF
然后重新继续安装
最后opencv3就被完整地安装在usr/local下面的个opencv3文件夹
编译成功如下:
[100%] Linking CXX executable ../../bin/opencv_perf_stitching
[100%] Built target opencv_perf_stitching
[100%] Linking CXX executable ../../bin/opencv_test_calib3d
[100%] Built target opencv_test_calib3d
[100%] Linking CXX shared module ../../lib/cv2.so
[100%] Built target opencv_python
安装如下:
Set runtime path of "/usr/local/opencv3/bin/opencv_traincascade" to "/usr/local/opencv3/lib"
-- Installing: /usr/local/opencv3/bin/opencv_createsamples
-- Set runtime path of "/usr/local/opencv3/bin/opencv_createsamples" to "/usr/local/opencv3/lib"
-- Installing: /usr/local/opencv3/bin/opencv_annotation
-- Set runtime path of "/usr/local/opencv3/bin/opencv_annotation" to "/usr/local/opencv3/lib"
-- Installing: /usr/local/opencv3/bin/opencv_visualisation
-- Set runtime path of "/usr/local/opencv3/bin/opencv_visualisation" to "/usr/local/opencv3/lib"
-- Installing: /usr/local/opencv3/bin/opencv_version
-- Set runtime path of "/usr/local/opencv3/bin/opencv_version" to "/usr/local/opencv3/lib"
查看是否安装成功
pkg-config --modversion opencv
缺失了opencv.pc这个配置信息文件:
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
解决办法:
sudo apt install libopencv-dev
三、例程测试
1.imageBasics
1.1CMakeLists.txt :
修改为:
set( CMAKE_CXX_FLAGS "-std=c++11")
cmake_minimum_required( VERSION 2.8 )
project( imageBasics )
set(OpenCV_DIR "usr/local/opencv3/share/OpenCV")
# 寻找OpenCV库
find_package( OpenCV REQUIRED )
# 添加头文件
include_directories( ${OpenCV_INCLUDE_DIRS} )
# 可执行程序
add_executable( imageBasics imageBasics.cpp )
# 链接OpenCV库
target_link_libraries( imageBasics ${OpenCV_LIBS} )
add_executable(undistortImage undistortImage.cpp)
# 链接OpenCV库
target_link_libraries(undistortImage ${OpenCV_LIBS})
1.2执行:
./imageBasics /home/sfann/sf_slam_temp_code/ch5/imageBasics/ubuntu.png
1.3结果:
图像宽为1200,高为674,通道数为3
Gtk-Message: 15:27:46.145: Failed to load module "canberra-gtk-module"
1.4报错:Gtk-Message: 16:09:54.200: Failed to load module "canberra-gtk-module"解决方法
执行操作:
sudo apt-get install libcanberra-gtk-module
2.undistortImage
测试图像去畸变
2.1CMakeLists:
# 可执行程序
add_executable(undistortImage undistortImage.cpp)
# 链接OpenCV库
target_link_libraries(undistortImage ${OpenCV_LIBS})
2.2运行:
./undistortImage /home/sfann/sf_slam_temp_code/ch5/imageBasics/distorted.png
2.3代码运行报错:
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/sfann/sf_slam_temp_code/ch2/opencv-3.2.0/modules/highgui/src/window.cpp, line 304
terminate called after throwing an instance of 'cv::Exception'
what(): /home/sfann/sf_slam_temp_code/ch2/opencv-3.2.0/modules/highgui/src/window.cpp:304: error: (-215) size.width>0 && size.height>0 in function imshow
已放弃 (核心已转储)
2.4解决方案:
图片和undistortImage 不再同一文件夹。复制到build中即可。
./undistortImage /home/sfann/sf_slam_temp_code/ch5/imageBasics/distorted.png
2.5运行结果:
3.stereoVision
3.1CMakeLists.txt :
project(stereo)
cmake_minimum_required(VERSION 3.2)
# 链接OpenCV库
#find_package( OpenCV REQUIRED )
find_package(Pangolin REQUIRED)
find_package(OpenCV 3.2 REQUIRED) #由于好几个版本所以这里指定个高版本的
include_directories(${OpenCV_INCLUDE_DIRS})
#添加Eigen头文件
include_directories("/usr/include/eigen3") #根据你的安装路径来选择
set(CMAKE_CXX_FLAGS "-std=c++11")
#set(CMAKE_CXX_STANDARD 17)
add_executable(stereoVision stereoVision.cpp)
target_link_libraries(stereoVision ${OpenCV_LIBS} ${Pangolin_LIBRARIES})
3.2修改图片路径:
// 文件路径
string left_file = "../left.png";
string right_file = "../right.png";
3.3编译结果:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sfann/sf_slam_temp_code/ch5/stereo/build
3.4make报错:
/usr/local/include/sigslot/signal.hpp:1077:23: note: suggested alternative: ‘Pmf’
return typeid(pmf);
^~~
Pmf
/usr/local/include/sigslot/signal.hpp: At global scope:
/usr/local/include/sigslot/signal.hpp:1115:27: error: ‘conditional_t’ in namespace ‘std’ does not name a template type
using cow_type = std::conditional_t<is_thread_safe<L>::value,
^~~~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1119:32: error: ‘conditional_t’ in namespace ‘std’ does not name a template type
using cow_copy_type = std::conditional_t<is_thread_safe<L>::value,
^~~~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1201:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t<trait::is_callable_v<arg_list, Callable>, connection>
^~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1221:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t<trait::is_callable_v<ext_arg_list, Callable>, connection>
^~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1241:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t<trait::is_callable_v<arg_list, Pmf, Ptr> &&
^~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1261:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t<trait::is_callable_v<arg_list, Pmf, Ptr> &&
^~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1281:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t<trait::is_callable_v<ext_arg_list, Pmf, Ptr> &&
^~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1310:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t<!trait::is_callable_v<arg_list, Pmf> &&
^~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1340:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t<trait::is_callable_v<arg_list, Callable> &&
^~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1376:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t<(trait::is_callable_v<arg_list, Callable> ||
^~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1399:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t<!trait::is_callable_v<arg_list, Obj> &&
^~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1522:12: error: ‘cow_copy_type’ does not name a type; did you mean ‘lock_type’?
inline cow_copy_type<list_type, Lockable> slots_reference() {
^~~~~~~~~~~~~
lock_type
/usr/local/include/sigslot/signal.hpp:1529:36: error: ‘make_slot’ function uses ‘auto’ type specifier without trailing return type
inline auto make_slot(A && ...a) {
^
/usr/local/include/sigslot/signal.hpp:1529:36: note: deduced return type only available with -std=c++14 or -std=gnu++14
/usr/local/include/sigslot/signal.hpp:1589:5: error: ‘cow_type’ does not name a type; did you mean ‘lock_type’?
cow_type<list_type, Lockable> m_slots;
^~~~~~~~
lock_type
/usr/local/include/sigslot/signal.hpp: In constructor ‘sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::signal_base(sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >&&)’:
/usr/local/include/sigslot/signal.hpp:1146:14: error: ‘m_slots’ was not declared in this scope
swap(m_slots, o.m_slots);
^~~~~~~
/usr/local/include/sigslot/signal.hpp:1146:14: note: suggested alternative: ‘m_block’
swap(m_slots, o.m_slots);
^~~~~~~
m_block
/usr/local/include/sigslot/signal.hpp: In member function ‘sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >& sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::operator=(sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >&&)’:
/usr/local/include/sigslot/signal.hpp:1155:14: error: ‘m_slots’ was not declared in this scope
swap(m_slots, o.m_slots);
^~~~~~~
/usr/local/include/sigslot/signal.hpp:1155:14: note: suggested alternative: ‘m_block’
swap(m_slots, o.m_slots);
^~~~~~~
m_block
/usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::operator()(U&& ...)’:
/usr/local/include/sigslot/signal.hpp:1180:9: error: ‘cow_copy_type’ was not declared in this scope
cow_copy_type<list_type, Lockable> ref = slots_reference();
^~~~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1180:9: note: suggested alternative: ‘lock_type’
cow_copy_type<list_type, Lockable> ref = slots_reference();
^~~~~~~~~~~~~
lock_type
/usr/local/include/sigslot/signal.hpp:1180:32: error: expected primary-expression before ‘,’ token
cow_copy_type<list_type, Lockable> ref = slots_reference();
^
/usr/local/include/sigslot/signal.hpp:1180:42: error: expected primary-expression before ‘>’ token
cow_copy_type<list_type, Lockable> ref = slots_reference();
^
/usr/local/include/sigslot/signal.hpp:1180:44: error: ‘ref’ was not declared in this scope
cow_copy_type<list_type, Lockable> ref = slots_reference();
^~~
/usr/local/include/sigslot/signal.hpp:1180:44: note: suggested alternative:
In file included from /usr/include/c++/7/bits/std_function.h:44:0,
from /usr/include/c++/7/functional:58,
from /usr/include/eigen3/Eigen/Core:262,
from /home/sfann/sf_slam_temp_code/ch5/stereo/stereoVision.cpp:4:
/usr/include/c++/7/bits/refwrap.h:382:5: note: ‘std::ref’
ref(reference_wrapper<_Tp> __t) noexcept
^~~
In file included from /usr/local/include/pangolin/utils/signal_slot.h:3:0,
from /usr/local/include/pangolin/windowing/window.h:35,
from /usr/local/include/pangolin/display/display.h:34,
from /usr/local/include/pangolin/pangolin.h:38,
from /home/sfann/sf_slam_temp_code/ch5/stereo/stereoVision.cpp:5:
/usr/local/include/sigslot/signal.hpp:1180:50: error: there are no arguments to ‘slots_reference’ that depend on a template parameter, so a declaration of ‘slots_reference’ must be available [-fpermissive]
cow_copy_type<list_type, Lockable> ref = slots_reference();
^~~~~~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1180:50: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/usr/local/include/sigslot/signal.hpp: In member function ‘size_t sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::disconnect(const Callable&, const Obj&)’:
/usr/local/include/sigslot/signal.hpp:1423:41: error: use of ‘auto’ in lambda parameter declaration only available with -std=c++14 or -std=gnu++14
return disconnect_if([&] (const auto &s) {
^~~~
/usr/local/include/sigslot/signal.hpp: In lambda function:
/usr/local/include/sigslot/signal.hpp:1424:21: error: base operand of ‘->’ is not a pointer
return s->has_object(obj) && s->has_callable(c);
^~
/usr/local/include/sigslot/signal.hpp:1424:43: error: base operand of ‘->’ is not a pointer
return s->has_object(obj) && s->has_callable(c);
^~
/usr/local/include/sigslot/signal.hpp: In member function ‘size_t sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::disconnect(sigslot::group_id)’:
/usr/local/include/sigslot/signal.hpp:1439:46: error: ‘m_slots’ was not declared in this scope
for (auto &group : detail::cow_write(m_slots)) {
^~~~~~~
/usr/local/include/sigslot/signal.hpp:1439:46: note: suggested alternative: ‘m_block’
for (auto &group : detail::cow_write(m_slots)) {
^~~~~~~
m_block
/usr/local/include/sigslot/signal.hpp: In member function ‘size_t sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::slot_count()’:
/usr/local/include/sigslot/signal.hpp:1486:9: error: ‘cow_copy_type’ was not declared in this scope
cow_copy_type<list_type, Lockable> ref = slots_reference();
^~~~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:1486:9: note: suggested alternative: ‘lock_type’
cow_copy_type<list_type, Lockable> ref = slots_reference();
^~~~~~~~~~~~~
lock_type
/usr/local/include/sigslot/signal.hpp:1486:32: error: expected primary-expression before ‘,’ token
cow_copy_type<list_type, Lockable> ref = slots_reference();
^
/usr/local/include/sigslot/signal.hpp:1486:42: error: expected primary-expression before ‘>’ token
cow_copy_type<list_type, Lockable> ref = slots_reference();
^
/usr/local/include/sigslot/signal.hpp:1486:44: error: ‘ref’ was not declared in this scope
cow_copy_type<list_type, Lockable> ref = slots_reference();
^~~
/usr/local/include/sigslot/signal.hpp:1486:44: note: suggested alternative:
In file included from /usr/include/c++/7/bits/std_function.h:44:0,
from /usr/include/c++/7/functional:58,
from /usr/include/eigen3/Eigen/Core:262,
from /home/sfann/sf_slam_temp_code/ch5/stereo/stereoVision.cpp:4:
/usr/include/c++/7/bits/refwrap.h:382:5: note: ‘std::ref’
ref(reference_wrapper<_Tp> __t) noexcept
^~~
In file included from /usr/local/include/pangolin/utils/signal_slot.h:3:0,
from /usr/local/include/pangolin/windowing/window.h:35,
from /usr/local/include/pangolin/display/display.h:34,
from /usr/local/include/pangolin/pangolin.h:38,
from /home/sfann/sf_slam_temp_code/ch5/stereo/stereoVision.cpp:5:
/usr/local/include/sigslot/signal.hpp:1486:50: error: there are no arguments to ‘slots_reference’ that depend on a template parameter, so a declaration of ‘slots_reference’ must be available [-fpermissive]
cow_copy_type<list_type, Lockable> ref = slots_reference();
^~~~~~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::clean(sigslot::detail::slot_state*)’:
/usr/local/include/sigslot/signal.hpp:1504:46: error: ‘m_slots’ was not declared in this scope
for (auto &group : detail::cow_write(m_slots)) {
^~~~~~~
/usr/local/include/sigslot/signal.hpp:1504:46: note: suggested alternative: ‘m_block’
for (auto &group : detail::cow_write(m_slots)) {
^~~~~~~
m_block
/usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::add_slot(sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::slot_ptr&&)’:
/usr/local/include/sigslot/signal.hpp:1538:42: error: ‘m_slots’ was not declared in this scope
auto &groups = detail::cow_write(m_slots);
^~~~~~~
/usr/local/include/sigslot/signal.hpp:1538:42: note: suggested alternative: ‘m_block’
auto &groups = detail::cow_write(m_slots);
^~~~~~~
m_block
/usr/local/include/sigslot/signal.hpp: In member function ‘size_t sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::disconnect_if(Cond&&)’:
/usr/local/include/sigslot/signal.hpp:1560:42: error: ‘m_slots’ was not declared in this scope
auto &groups = detail::cow_write(m_slots);
^~~~~~~
/usr/local/include/sigslot/signal.hpp:1560:42: note: suggested alternative: ‘m_block’
auto &groups = detail::cow_write(m_slots);
^~~~~~~
m_block
/usr/local/include/sigslot/signal.hpp:1564:28: error: range-based ‘for’ expression of type ‘auto’ has incomplete type
for (auto &group : groups) {
^~~~~~
/usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::clear()’:
/usr/local/include/sigslot/signal.hpp:1584:27: error: ‘m_slots’ was not declared in this scope
detail::cow_write(m_slots).clear();
^~~~~~~
/usr/local/include/sigslot/signal.hpp:1584:27: note: suggested alternative: ‘m_block’
detail::cow_write(m_slots).clear();
^~~~~~~
m_block
/usr/local/include/sigslot/signal.hpp: In instantiation of ‘void sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::operator()(U&& ...) [with U = {pangolin::VarState::Event}; Lockable = std::mutex; T = {pangolin::VarState::Event}]’:
/usr/local/include/pangolin/var/varstate.h:264:23: required from ‘std::map<std::__cxx11::basic_string<char>, std::shared_ptr<pangolin::VarValueGeneric> >::iterator pangolin::VarState::AddUpgradedVar(const std::shared_ptr<pangolin::VarValue<T> >&, const iterator&, bool) [with T = bool; std::map<std::__cxx11::basic_string<char>, std::shared_ptr<pangolin::VarValueGeneric> >::iterator = std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<pangolin::VarValueGeneric> > >]’
/usr/local/include/pangolin/var/varstate.h:205:13: required from ‘std::shared_ptr<pangolin::VarValueGeneric> pangolin::VarState::GetOrCreateVar(const T&, const pangolin::VarMeta&) [with T = bool]’
/usr/local/include/pangolin/var/var.h:83:50: required from ‘pangolin::Var<T>::Var(const T&, const pangolin::VarMeta&) [with T = bool]’
/usr/local/include/pangolin/var/var.h:88:35: required from ‘pangolin::Var<T>::Var(const string&, const T&) [with T = bool; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/usr/local/include/pangolin/display/widgets.h:153:50: required from here
/usr/local/include/sigslot/signal.hpp:1180:65: error: ‘slots_reference’ was not declared in this scope
cow_copy_type<list_type, Lockable> ref = slots_reference();
~~~~~~~~~~~~~~~^~
CMakeFiles/stereoVision.dir/build.make:81: recipe for target 'CMakeFiles/stereoVision.dir/stereoVision.cpp.o' failed
CMakeFiles/Makefile2:94: recipe for target 'CMakeFiles/stereoVision.dir/all' failed
make[3]: *** [CMakeFiles/stereoVision.dir/stereoVision.cpp.o] Error 1
make[2]: *** [CMakeFiles/stereoVision.dir/all] Error 2
CMakeFiles/Makefile2:101: recipe for target 'CMakeFiles/stereoVision.dir/rule' failed
make[1]: *** [CMakeFiles/stereoVision.dir/rule] Error 2
Makefile:137: recipe for target 'stereoVision' failed
make: *** [stereoVision] Error 2
原因:由于我下载的是最新版本的Pangolin(目前是Pangolin0.6
)而Pangolin0.6用的是C++17
标准编译。而ORB_SLAM2 和 slambook2 的代码用的还是C++11
,因此报了一大堆不明error。
解决办法:
在CMakeLists中修改:
#set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CXX_STANDARD 17)
3.5执行结果:
4.stereoVision
4.1CMakeLists:
project(rgbd)
cmake_minimum_required(VERSION 3.10)
find_package(Sophus REQUIRED)
add_executable(joinMap joinMap.cpp)
#add_executable(joinMap1 joinMap1.cpp)
include_directories(${Sophus_INCLUDE_DIRS})
#链接OpenCV库
find_package(OpenCV REQUIRED)
#添加头文件
include_directories( ${OpenCV-INCLUDE_DIRS})
target_link_libraries(joinMap ${OpenCV_LIBS} ${Pangolin_LIBRARIES})
find_package(Pangolin REQUIRED)
target_link_libraries(joinMap ${OpenCV_LIBS} ${Pangolin_LIBRARIES})
# Eigen
include_directories("/usr/include/eigen3")
target_link_libraries(joinMap ${Sophus_LIBRARIES} fmt)
#链接c++11
set(CMAKE_CXX_FLAGS "-std=c++14")
4.2执行结果:
转换图像中: 1
转换图像中: 2
转换图像中: 3
转换图像中: 4
转换图像中: 5
点云共有0个点.
Point cloud is empty!
原因:修改路径
4.3结果:
转换图像中: 1
转换图像中: 2
转换图像中: 3
转换图像中: 4
转换图像中: 5
点云共有1081843个点.