OpenCV GTK+2.x error

2020-02-01 00:56发布

I had installed OpenCV following these steps (). After trying to compile one examples,i got this error :

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/nick/.Apps/opencv/modules/highgui/src/window.cpp, line 516
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/nick/.Apps/opencv/modules/highgui/src/window.cpp:516: 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

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.4)
project(threadTest)

find_package( OpenCV REQUIRED )


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pthread")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "/home/nick/ClionProjects/threadTest")

set(SOURCE_FILES main.cpp)
add_executable(threadTest ${SOURCE_FILES})
target_link_libraries( threadTest ${OpenCV_LIBS} )

How to solve it?

12条回答
SAY GOODBYE
2楼-- · 2020-02-01 01:24

For me (Arch Linux, Anaconda with Python 3.6), installing from the suggested channels menpo or loopbio did not change anything. My solution was to

  1. install pkg-config (sudo pacman -Syu pkg-config),
  2. remove opencv from the environment (conda remove opencv) and
  3. re-install opencv from the conda-forge channel (conda install -c conda-forge opencv)

conda list now returns opencv 3.3.0 py36_blas_openblas_203 [blas_openblas] conda-forgeand all windows launched using cv2 are working fine.

查看更多
Evening l夕情丶
3楼-- · 2020-02-01 01:29

I had the same problem, and fixed it by simply reinstalling opencv.

There is no need to uninstall it first.

查看更多
做个烂人
4楼-- · 2020-02-01 01:32

I have had to deal with this issue a couple of times, this is what has worked consistently thus far:

conda remove opencv
conda install -c menpo opencv
pip install --upgrade pip
pip install opencv-contrib-python
查看更多
Explosion°爆炸
5楼-- · 2020-02-01 01:34

I have fixed this issue by replacing

cvDestroyWindow("showImage");

by

cvDestroyWindow("ShowImage");
查看更多
啃猪蹄的小仙女
6楼-- · 2020-02-01 01:37

In case what they mentioned above doesn't work, try:

pip install opencv-python

for python2, or

pip3 install opencv-python

for python3

查看更多
家丑人穷心不美
7楼-- · 2020-02-01 01:38

First check whether libgtk2.0-dev is installed properly. If you have installed aptitude package manager, run the following:

sudo aptitude search libgtk2.0-dev

It should return like this:

i  libgtk2.0-dev              - development files for the GTK+ library 
p  libgtk2.0-dev:i386         - development files for the GTK+ library

You need to build the files once again.Locate your OpenCV folder. Create a new folder and name it as release. Enter into this folder. For example

cd /home/user_name/OpenCv
mkdir Release
cd Release

Now build using cmake with following command:

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 INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON ..

Remember to put WITH_GTK=ON during cmake. After this step enter the command,

make
sudo make install

This should resolve your problem.If you have broken dependencies for libgtk2.0-dev, then install a fresh copy of libgtk2.0-dev using aptitude.

sudo aptitude install libgtk2.0-dev
查看更多
登录 后发表回答