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目录结构:

The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support_第1张图片

以前的编译命令:

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

The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support_第2张图片

 程序正常运行。

参考博客:

If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config_绿竹巷人的博客-CSDN博客

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