2

I have some errors with python3 when I want to use opencv. It works well with python2 but not python3.

import cv2
import numpy as np

img = cv2.imread('test.jpg')
print(img)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()`

The code I used.

I received 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 cvShowImage, file /io/opencv/modules/highgui/src/window.cpp, line 583
Traceback (most recent call last):
  File "test.py", line 6, 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

So I tried to reinstall opencv with these parameters :

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_2_X=ON  -D CUDA_GENERATION=Kepler ..

But it doesn't work, I receive the same error. (sudo make -j8 then sudo make install)

Moreover I am not sure GTK is taking in account by cmake because of these lines :

GUI: 
--     QT 5.x:                      YES (ver 5.5.1)
--     QT OpenGL support:           YES (Qt5::OpenGL 5.5.1)
--     OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so)
--     VTK support:                 YES (ver 6.2.0)
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8

How can I solve this problem?

1 Answer 1

0

You may try

conda install -c loopbio -c conda-forge -c pkgw-forge ffmpeg-feature ffmpeg gtk2 opencv

You may see the following error after conda install

Traceback (most recent call last):
    File "./test.py", line 21, in <module>
      import cv2
ImportError: libopenblas.so.0: cannot open shared object file: No such file or directory

Just install openblas library would solve

apt install libopenblas-dev -y

Reference

[sdvillal | github] https://github.com/conda-forge/opencv-feedstock/issues/43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .