tony1812
Posts: 350
Joined: Sat Jul 15, 2017 12:40 pm
Location: Boston MA.

compiling opencv

Sun Jan 21, 2018 4:35 pm

Hello, Following this link https://www.pyimagesearch.com/2017/09/ ... berry-pi/ I compiled opencv successfully. But after using it for awhile, I found that it is more a drag to use virtualenv so I want to take it out of it. ( I am just learning opencv, not for developing.)
Question1, can I simply take it out of the virtualenv without the need to re-compile? If so, how?
Question2, I did try re-compiling base on the same link but skipped the entire virtualenv process, it seem to compile fine, but when I run a script that has cv2.imshow function, I got this opencv error:

Code: Select all

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, , then re-run cmake or configure script) in cvShowImage, file /home/pi/opencv-3.3.0/modules/highgui/src/window.cpp, line 605
Traceback (most recent call last):
  File "/home/pi/Desktop/Pi_Projects/NewCV/cv.py", line 30, in <module>
    cv2.imshow('img',img)
cv2.error: /home/pi/opencv-3.3.0/modules/highgui/src/window.cpp:605: 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
Mine is the Raspbian Stretch, so it is Debian.
Here is what I don't understand

Code: Select all

install libgtk2.0-dev and pkg-config
, I already installed libgtk2.0-dev, but how do I configure script in function cvShowImage?
My makefile looks like this:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D WITH_GTK=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules
-D BUILD_EXAMPLES=ON ..
What am I doing wrong?
Thanks.

asavah
Posts: 347
Joined: Thu Aug 14, 2014 12:49 am

Re: compiling opencv

Sun Jan 21, 2018 7:21 pm

Don't know if its typing or copy/paste error but
cmake options are written as a single word (no spaces, if the value you are passing via the var contains spaces it needs to be quoted):

wrong:

Code: Select all

-D WHATEVER_FOO_BAR=BAZ

right:

Code: Select all

-DWHATEVER_FOO_BAR=BAZ
Note: cmake actually _should_ understand -D var= with space, but it's behavior is not consistent and could cause issues,
thus it's recommended to avoid spaces.

tony1812
Posts: 350
Joined: Sat Jul 15, 2017 12:40 pm
Location: Boston MA.

Re: compiling opencv

Tue Jan 23, 2018 6:39 pm

Thanks for the reply. No it's not a typo I copy and paste it for the tutorial and it compiles, it was nothing to do with the errors, Anyhow, I managed to compile it without the virtualenv in python3, works like a champ! :)

divya.bhargava
Posts: 2
Joined: Fri May 11, 2018 10:03 am

Re: compiling opencv

Fri Jul 13, 2018 7:10 am

Hi, I am also getting the same error, please share the steps you followed to fix this issue. and compile openCV as I am also new for open CV,

Return to “Python”

Who is online

Users browsing this forum: onlinegill and 4 guests