安装ORB-SLAM2纯记录(caffe)

ubuntu20.04
显卡配置3050TI 显卡驱动: NVIDIA-SMI 525.116.04 Driver Version: 525.116.04
cuda:Cuda compilation tools, release 11.0, V11.0.221

eigen:3.4.0

opencv 3.4.9
opencv下载链接
pangolin :高翔SLAM十四讲中的 没有安装最新版本
安装pangolin时候出现的问题,据说是安装ffmpeg依赖后,与pangolin版本冲突,所以直接将
在pangolin/src文件夹下,找到CMakeLists.txt文件,打开,并在266行将以下代码注释。

find_package(FFMPEG QUIET)
if(BUILD_PANGOLIN_VIDEO AND FFMPEG_FOUND)
  set(HAVE_FFMPEG 1)
  list(APPEND INTERNAL_INC  ${FFMPEG_INCLUDE_DIRS} )
  list(APPEND LINK_LIBS ${FFMPEG_LIBRARIES} )
  list(APPEND HEADERS ${INCDIR}/video/drivers/ffmpeg.h)
  list(APPEND SOURCES video/drivers/ffmpeg.cpp)
  message(STATUS "ffmpeg Found and Enabled")
endif()

参考:https://blog.csdn.net/qin__han/article/details/123474879
不知道这样子对之后使用有没有问题,总之pangolin

提供下载pangolin地址:https://github.com/stevenlovegrove/Pangolin/tags

之后安装ORB-SLAM2时候出现报错1:

/usr/include/c++/9/bits/stl_map.h: In instantiation of ‘class std::map<ORB_SLAM2::KeyFrame*, g2o::Sim3, std::less<ORB_SLAM2::KeyFrame*>, Eigen::aligned_allocator<std::pair<const ORB_SLAM2::KeyFrame*, g2o::Sim3> > >:
/home/ckq/Projects/orb_-slam2_yuanban-vscode/src/LoopClosing.cc:438:21:   required from here
/usr/include/c++/9/bits/stl_map.h:122:71: error: static assertion failed: std::map must have the same value_type as its allocator
  122 |       static_assert(is_same<typename _Alloc::value_type, value_type>::value,

之前安装从来没出现过这个问题

参考链接:https://blog.csdn.net/ABC_ORANGE/article/details/118497033

解决办法: 打开LoopClosing.h,将

ypedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
        Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;

改为:

typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
        Eigen::aligned_allocator<std::pair<KeyFrame *const, g2o::Sim3> > > KeyFrameAndPose;

解释:
https://zhuanlan.zhihu.com/p/218019316

安装ROS

参考链接:详细介绍如何在ubuntu20.04中安装ROS系统

亲测可以使用!!!

ubuntu还源:
https://blog.csdn.net/qq_44339029/article/details/108916820

ubuntu20.04禁止内核升级 导致无法登陆
参考0
参考1

操作1:

sudo gedit /etc/apt/apt.conf.d/10periodic

改为:

APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";

操作2:

sudo gedit /etc/apt/apt.conf.d/20auto-upgrades

改为:

APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";

改完后重启电脑!!

安装caffe

protobuf版本太高了 卸载

protoc --version
libprotoc 3.6.1

系统一开始版本

卸载
https://blog.csdn.net/m0_49448331/article/details/107734989

sudo apt-get remove libprotobuf-dev

ckq@ckq:~$ which protoc
/usr/bin/protoc

sudo rm /usr/bin/protoc

安装libprotoc3.5.1

安装连接:https://blog.csdn.net/qq_39779233/article/details/123707257

可以看看
参考


caffe make all出现的问题

[ 89%] Linking CXX executable upgrade_net_proto_text
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyUnicode_InternFromString'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `_Py_Dealloc'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyModule_Create2'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyType_GetFlags'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `_Py_fopen'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyUnicode_FromString'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyBytes_AsString'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyBytes_Size'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyUnicode_AsWideChar'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyUnicode_FromEncodedObject'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyUnicode_AsUTF8'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyUnicode_AsUTF8String'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyUnicode_FromFormat'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `_Py_tracemalloc_config'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `PyUnicode_FromStringAndSize'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_python38.so.1.71.0: undefined reference to `_PyTraceMalloc_NewReference'
collect2: error: ld returned 1 exit status
make[2]: *** [tools/CMakeFiles/upgrade_net_proto_text.dir/build.make:127: tools/upgrade_net_proto_text] Error 1
make[1]: *** [CMakeFiles/Makefile2:511: tools/CMakeFiles/upgrade_net_proto_text.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

打开cd /usr/lib/x86_64-linux-gnu
查找

find . -name "*libboost_python3*" | xargs ls -l

安装ORB-SLAM2纯记录(caffe)_第1张图片
安装ORB-SLAM2纯记录(caffe)_第2张图片

ubuntu20.04中的python默认版本就是3.8 而cmake中用的是python2导致 找不到cmake在编译的时候找不到动态链接库。网上有一些其他操作 但是感觉有问题。没想好是否采用。所以我就切换系统的python版本一下 在编译一下caffe!!!
发现本cmake 中 使用的Python2.7
– Python:
– Interpreter : /usr/bin/python2.7 (ver. 2.7.18)
– Libraries : /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.18)
– NumPy : /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.5)

而我默认的是python3.8

那我切换python版本试一下 给两个python设置一个优先级别

第一步查看 是否安装 python2 和python3

第二步:下面两条命令将/usr/bin/python2.7优先级设置为1,将/usr/bin/python3.8的优先级设置为2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2

第三步:显示python可替换版本
sudo update-alternatives --config python

链接:https://blog.csdn.net/cocapop/article/details/129797922

或者在bashrc中设置
可见链接:http://www.javashuo.com/article/p-syxqollf-mv.html

切换系统版本的python在编译 还是出现同样的问题!!!

看来还是得用python3

修改caffe中cmakelists中的内容:

set(python_version “2” CACHE STRING “Specify which Python version to use”)
改为
set(python_version “3” CACHE STRING “Specify which Python version to use”)

不知道这样可不可以
总之 cmake出来的时候现实的python3
但make all 不知道有没有兼容问题

参考链接C++ CMake 使用 Python3
https://blog.csdn.net/weixin_40448140/article/details/112005184

编译ORB-SLAM2的build.sh报错

/usr/include/c++/9/bits/stl_map.h:122:71: error: static assertion failed: std::map must have the same value_type as its allocator
122 | static_assert(is_same::value,
| ^~~~~

出现了非典型报错: error: static assertion failed: std::map must have the same value_type as its allocator。查阅资料发现是因为libc++ 3.8.0为自定义std::map分配器添加了这些完整性检查,其中分配器必须为为std::pair的类型。也就是说这里需要将Loopclosing.h中的:

在LoopClosing.h中修改: 50行
typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
    Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;

改完

typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
    Eigen::aligned_allocator<std::pair<KeyFrame* const, g2o::Sim3> > > KeyFrameAndPose;

参考1:https://blog.csdn.net/weixin_46808875/article/details/125317128

参考链接:https://github.com/raulmur/ORB_SLAM2/pull/585

你可能感兴趣的:(caffe,人工智能)