问题:在正确安装ORBSLAM3及所有依赖库后,运行单目例程时报错:
Initialization of Atlas from scratch Creation of new map with id: 0 Creation of new map with last KF id: 0 Seq. Name: There are 1 cameras in the atlas Camera 0 is pinhole First KF:0; Map init KF:0 New Map created with 271 points terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(3.4.10) /home/mm93/Environment_library/opencv-3.4.10/modules/highgui/src/window.cpp:641: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'
已放弃 (核心已转储)
原因:
尝试使用OpenCV创建图形界面(GUI)窗口时缺乏必要的GUI库支持。OpenCV的highgui
模块依赖于GUI库来创建和管理窗口,显示图像和视频。在Ubuntu或Debian系统上,通常需要GTK+ 2.x库来提供这种支持。即缺少libgtk2.0-dev 和 pkg-config库。(本人已安装,仍报错)
解决:
1,未安装libgtk2.0-dev 和 pkg-config库可跳过这一步
卸载pkg-config
和libgtk2.0-dev
sudo apt-get remove --purge pkg-config libgtk2.0-dev
卸载已安装opencv(重新编译应该也可)
本人是源码安装,进入opencv安装文件夹的build文件,打开终端
sudo make uninstall
2,切换台湾下载源 https://ftp.tc.edu.tw/Linux/ubuntu(中国的第一个源),大陆的源在安装类似依赖库,可能会有部分缺少
重新安装libgtk2.0-dev 和 pkg-config库
sudo apt-get update
sudo apt-get install pkg-config libgtk2.0-dev
3,重新编译安装opencv
进入opencv源码文件
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES ..
make -j$(nproc)
sudo make install
最后重新编译ORBSLAM3文件(个人建议,直接删除重新解压一个)
cd ORB_SLAM3-master
sudo chmod +x build.sh
sudo ./build.sh