Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV GTK+2.x error - "Unspecified error (The function is not implemented...)"

Tags:

I had installed OpenCV following these steps. After trying to compile one example, 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 can I solve it?

like image 992
Maxian Nicu Avatar asked Feb 27 '15 23:02

Maxian Nicu


People also ask

How do I tell what version of OpenCV is installed?

After installation, it is recommended that you can check the version of OpenCV that Python is using: import cv2 print cv2. __version__ # Should print 3.0.

How do I view cv2 images?

To read and display image using OpenCV Python, you could use cv2. imread() for reading image to a variable and cv2. imshow() to display the image in a separate window.


2 Answers

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 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 
like image 97
KiranCP Avatar answered Sep 17 '22 09:09

KiranCP


If you installed OpenCV using the opencv-python pip package, be aware of the following note, taken from opencv-python:

IMPORTANT NOTE
macOS and Linux wheels have currently some limitations:

  • video related functionality is not supported (not compiled with FFmpeg)
  • for example cv2.imshow() will not work (not compiled with GTK+ 2.x or Carbon support)

Also note that to install from another source, first you must remove the opencv-python package.

To install OpenCV in Ubuntu, I followed this guide, and it worked perfectly fine: Ubuntu 16.04: How to install OpenCV

like image 44
Nic Szerman Avatar answered Sep 19 '22 09:09

Nic Szerman