当我运行我的c++代码时,我得到这个错误:
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.1.0) /home/me/opencv/modules/highgui/src/window.cpp:610:
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 pkg-config -y
重新运行cmake后,同样的错误仍然存在。
我有所有必要的导入:
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
这是抛出错误的代码行:
cv::namedWindow("input video", cv::WINDOW_NORMAL);
安装一个窗口开发库:
sudo apt-get install libgtk2.0-dev pkg-config
重建opencv:
cd build
cmake ../opencv-4.x
cmake --build .
sudo make install