Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

python - How to include libgtk2.0-dev and pkg-config in cmake when installing openCV on Ubuntu 16

I know there are many topics on how to install OpenCV-Python. I went over many of them and they helped me to go through some problems installing openCV-python on Ubuntu

I managed to install openCV but is not properly working. When I try to run:

import numpy
import cv2
img= cv2.imread('image.png',0)
cv2.imshow('image',img)

I get an error

error: /io/opencv/modules/highui/src/window.cpp:583: error: (-2) The function is not implemented. Rebuilt 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 cvSowImage

How do I do that? I suspect I should repeat cmake and somehow include these two libraries on it, but how?

EDIT March 19 2017 I followed instructions from:

http://milq.github.io/install-opencv-ubuntu-debian/

and

http://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/

and from:

http://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html

Everytime my script include (I am running from IDLE):

cv2.imshow('image',img)

I got the same error message:

Traceback (most recent call last):

      File "/home/dcanals/Documents/test.py", line 5, in <module>
        cv2.imshow('image',img)
    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

I rellay do not understand what is going on. I just want to have openCV to start learning this package. I have libgtk2 and pkg-config installed. I follow step by step the instructions. Why it is not working? What should I do now to get python-openCV working? Thank you

EDIT March 21 2017

I edit this post because I think I found very important documentation in: https://pypi.python.org/pypi/opencv-python

Where is written abouth the package 'opencv-python':

IMPORTANT NOTE:

MacOS and Linux wheels have some limitations:

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


SOLVED

I managed to make it work.

The problem was I had a mix of packages, that probably were incompatible. First time I tried to install OpenCV I used opencv-python package. It didn't work, so I tried to build the official opencv with python. Nothing worked.

The solution was to re-install Ubuntu 16.10 and re-install opencv from the official site.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

conda install -c menpo opencv=2.4.11

The solution is in this thread: OpenCV error: the function is not implemented

solves my problem on Ubuntu 14.04. Although you will require to have an Anaconda2 to be able to use this. but once you have the include and libs, you can take them out and use them with your program.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...