1

I am getting this error while running a simple Python3 with opencv program on ubuntu 16.10.

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 cvShowImage, file
/io/opencv/modules/highgui/src/window.cpp, line 583 Traceback (most
recent call last):   File "samplecv.py", line 3, in <module>
    cv2.imshow('image',img) cv2.error: /io/opencv/modules/highgui/src/window.cpp:583: 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 cvShowImage

The program I ran is:

  import cv2
    img = cv2.imread('my.jpg',0)
    cv2.imshow('image',img)

I have already checked similar questions this and this. And have re-installed opencv but it didnt help.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
tsukyonomi06
  • 514
  • 1
  • 6
  • 19
  • 1
    If you installed OpenCV through Python PIP, [it's well known that the Python wrappers are not compiled with GTK support](https://stackoverflow.com/a/43531919/3250829), so you are not able to show an image on the screen and hence those errors. The only choice you have is to compile the source to generate the right Python packages so that you can show images. These directions from PyImageSearch are quite good: http://pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/. Be prepared to spend between 30 minutes to an hour depending on your system configuration and setup. – rayryeng Aug 14 '17 at 07:12
  • thanks its done now. – tsukyonomi06 Aug 14 '17 at 14:08

2 Answers2

1

It took more than 2 hours but its done now! I went to this documentation of opencv and followed the step to install opencv 3.3.0-dev. After complete installation it was still not working so i uninstalled the opencv-python using

sudo pip3 uninstall opencv-python

now errors were not showing up but still the image was not displayed until i added

cv2.waitKey()

at the end of the program. Now its working fine!!!

tsukyonomi06
  • 514
  • 1
  • 6
  • 19
0

What you had tried is more suitable for python2. You are using python3 (as I can see from your question). I guess you're installing cv module using pip3 install command. It works but provides the module with decreased functionality: as you see for one from highgui module 'The function is not implemented.'

The solution: try the 1st answer from here and install opencv module manually step-by-step as described.

rayryeng
  • 102,964
  • 22
  • 184
  • 193
Alexey Antonenko
  • 2,389
  • 1
  • 18
  • 18
  • the `cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \ -D BUILD_EXAMPLES=ON` .. was giving error . Anyways i sorted it out thank you! – tsukyonomi06 Aug 14 '17 at 14:05