解决opencv测试时OpenCV Error: Unspecified error (The function is not implemented.的问题

在安装好opencv时,出现如下的报错信息:

OpenCV Error: 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 cvNamedWindow, file /home/aborn/software/OpenCV-3.4.7/modules/highgui/src/window.cpp, line 598
terminate called after throwing an instance of ‘cv::Exception’
what(): /home/aborn/software/OpenCV-3.4.7/modules/highgui/src/window.cpp:598: error: (-2) 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的时候,没有考虑到一些额外的依赖:
libgtk2.0-dev
pkg-config
这两个依赖环境是需要在opencv安装之前安装的;此时正确的做法是将之前安装好的opencv卸了,重新安装,在确保安装了opencv一些必要的依赖后,还需要安装libgtk2.0-dev和pkg-config。之后再进行编译、安装、配置环境

解决过程:

  1. 卸载之前安装的opencv:
    进入opencv的源代码文件夹下的build(这是你在安装opencv时候自己命名的,cmake时候所在的目录),依次执行如下命令:

make uninstall
cd ..
sudo rm -r release
sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv
  1. 再次安装:
    安装cmake
sudo apt-get install cmake

依赖环境

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg-dev libswscale-dev libtiff5-dev
sudo apt-get install libgtk2.0-dev
sudo apt-get install pkg-config

下载opencv(若已经下载,则跳过这步)
下载地址:https://opencv.org/releases/
点击Sources进行下载自己需要的版本
解决opencv测试时OpenCV Error: Unspecified error (The function is not implemented.的问题_第1张图片
解压文件
解压后,将文件夹放自己喜欢的地方,笔者这里就放在了home下
解决opencv测试时OpenCV Error: Unspecified error (The function is not implemented.的问题_第2张图片
进入到解压后的文件夹下
(这里我将解压后的文件夹重新命为opencv3,这个随便,不是重点)
在opencv3文件夹下新建build文件夹
解决opencv测试时OpenCV Error: Unspecified error (The function is not implemented.的问题_第3张图片

cd build

解决opencv测试时OpenCV Error: Unspecified error (The function is not implemented.的问题_第4张图片
cmake

sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..

接下来时一个漫长的等待过程,大概需要等10分钟,不用担心,耐心点…
解决opencv测试时OpenCV Error: Unspecified error (The function is not implemented.的问题_第5张图片
进行编译

sudo make -j8
可以使用sudo make -j 8 、sudo make -j4 、sudo make 
我这里就使用sudo make -j 8了

解决opencv测试时OpenCV Error: Unspecified error (The function is not implemented.的问题_第6张图片
进行安装

sudo make install

解决opencv测试时OpenCV Error: Unspecified error (The function is not implemented.的问题_第7张图片
到这里就结束了,希望可以解决你的问题

你可能感兴趣的:(原创,opencv)