在Ubuntu 16上安装openCV时如何在cmake中包含libgtk2.0-dev和pkg-config [英] How to include libgtk2.0-dev and pkg-config in cmake when installing openCV on Ubuntu 16

查看:422
本文介绍了在Ubuntu 16上安装openCV时如何在cmake中包含libgtk2.0-dev和pkg-config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有很多关于如何安装OpenCV-Python的主题. 我遍历了其中的许多内容,他们帮助我解决了在Ubuntu上安装openCV-python的一些问题

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

我设法安装了openCV,但不能正常工作.当我尝试运行时:

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)

我得到一个错误

错误:/io/opencv/modules/highui/src/window.cpp:583:错误:(-2) 功能未实现.使用Windows,GTK +重建库 2.x或Carbon支持.如果您使用的是Ubuntu或Debian,请安装libgtk2.0-dev和pkg-config,然后在其中重新运行cmake或配置脚本 函数cvSowImage

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

我该怎么做?我怀疑我应该重复cmake并以某种方式在其上包括这两个库,但是如何?

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

EDIT 2017年3月19日 我遵循了以下指示:

EDIT March 19 2017 I followed instructions from:

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

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

和来自:

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

每次我的脚本包括(我从IDLE运行):

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

我不明白发生了什么.我只是想让openCV开始学习此软件包.我安装了libgtk2和pkg-config.我按照说明进行操作.为什么它不起作用?我现在应该怎么做才能使python-openCV工作呢?谢谢

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 2017年3月21日

我编辑这篇文章是因为我认为我在以下地方找到了非常重要的文档: https://pypi.python.org/pypi/opencv-python

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

关于"opencv-python"包的内容:

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

重要提示:

MacOS和Linux轮子有一些局限性:

MacOS and Linux wheels have some limitations:

与视频相关的功能不受支持(未使用 FFmpeg),例如cv.imshow()将不起作用(未使用GTK +编译) 2.x或Carbon支持)

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)


已解决

我设法使它起作用.

问题是我混合使用了各种软件包,这些软件包可能不兼容. 第一次尝试安装OpenCV时,我使用的是opencv-python软件包.它没有用,所以我尝试用python构建官方的opencv.没事.

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.

解决方案是重新安装Ubuntu 16.10,然后从官方站点重新安装opencv.

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

推荐答案

conda install -c menpo opencv = 2.4.11

conda install -c menpo opencv=2.4.11

解决方案在此线程中: OpenCV错误:未实现该功能

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

解决了我在Ubuntu 14.04上的问题. 尽管您将需要具有Anaconda2才能使用它. 但是一旦有了include和lib,就可以将它们取出并在程序中使用它们.

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.

这篇关于在Ubuntu 16上安装openCV时如何在cmake中包含libgtk2.0-dev和pkg-config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆