本文主要是介绍The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
项目场景:
ros2 foxy 运行单目orb slam3
问题描述
编译正常,程序运行时报错如下
Loading ORB Vocabulary. This could take a while...
Vocabulary loaded!
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
slam changed
============================
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.2.0) /home/ros2/opencv4.4/opencv-4.4.0/modules/highgui/src/window.cpp:634: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa 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'
错误解决方案
按照系统给出的解决方案,执行命令
sudo apt-get install libgtk2.0-dev
sudo apt-get install pkg-config
并不能解决问题
原因分析:
问题出在,安装opencv时编译配置出现了问题。
正确的执行命令是:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.4.0/modules ../opencv-4.4.0
解决方案:
opencv目录结构:
以前的编译命令:
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.4.0/modules ../opencv-4.4.0
正确的编译执行命令:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.4.0/modules ../opencv-4.4.0
重新编译后运行:
ros2 run orbslam3 mono ~/ros2_ws/src/ORB_SLAM3/Vocabulary/ORBvoc.txt ~/ros2_ws/src/ORB_SLAM3/Examples/Monocular/EuRoC.yaml
程序正常运行。
参考博客:
If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config_绿竹巷人的博客-CSDN博客
这篇关于The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!