OpenCV错误:该功能未实现 [英] OpenCV error: the function is not implemented

查看:102
本文介绍了OpenCV错误:该功能未实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使Ubuntu计算机上的OpenCV与Python一起使用.我已经下载并安装了OpenCV,但是当我尝试运行以下python代码(应该从网络摄像头捕获图像并将其推送到屏幕上)时

I'm trying to get OpenCV working with Python on my Ubuntu machine. I've downloaded and installed OpenCV, but when I attempt to run the following python code (which should capture images from a webcam and push them to the screen)

import cv

cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
capture = cv.CaptureFromCAM(0)

def repeat():
    frame = cv.QueryFrame(capture)
    cv.ShowImage("w1", frame)
    time.sleep(10)

while True:
    repeat()

我收到以下错误:

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

所以我按照他们的要求去做:安装软件包,从我安装OpenCV的位置移动到该文件夹​​,然后运行

So I do what they ask: install the packages, move to the folder from whence I installed OpenCV, and run

sudo make uninstall
make
sudo make install

但是当我尝试运行python时,它给了我同样的错误.我想念什么吗?

But when I try to run the python, it gives me the same error. Am I missing something?

推荐答案

如果它给您带来gtk错误,请尝试qt.

If it's giving you errors with gtk, try qt.

sudo apt-get install libqt4-dev
cmake -D WITH_QT=ON ..
make
sudo make install

如果这不起作用,有一个简单的解决方法.

If this doesn't work, there's an easy way out.

sudo apt-get install libopencv-*

这将下载所有必需的依赖项(尽管您似乎已安装了所有必需的库,但仍然可以尝试一次).这可能会安装OpenCV 2.3.1(Ubuntu 12.04).但是,由于您在/usr/local/lib中具有OpenCV 2.4.3,因此在/etc/ld.so.conf中包含此路径并执行ldconfig.因此,现在无论何时使用OpenCV,您都将使用最新版本.这不是最好的方法,但是如果qt或gtk仍然有问题,请尝试一次.这应该起作用.

This will download all the required dependencies(although it seems that you have all the required libraries installed, but still you could try it once). This will probably install OpenCV 2.3.1 (Ubuntu 12.04). But since you have OpenCV 2.4.3 in /usr/local/lib include this path in /etc/ld.so.conf and do ldconfig. So now whenever you use OpenCV, you'd use the latest version. This is not the best way to do it but if you're still having problems with qt or gtk, try this once. This should work.

更新-2019年6月18日

Update - 18th Jun 2019

我在针对openCV 3.4.2的Ubuntu(18.04.1 LTS)系统上遇到此错误,因为对cv2.imshow的方法调用失败(例如,在cv2.namedWindow(name)行,错误为:cv2 .error:OpenCV(3.4.2).此功能未实现.我正在使用水蟒.仅以下两个步骤就帮助我解决了问题:

I got this error on my Ubuntu(18.04.1 LTS) system for openCV 3.4.2, as the method call to cv2.imshow was failing (e.g., at the line of cv2.namedWindow(name) with error: cv2.error: OpenCV(3.4.2). The function is not implemented.). I am using anaconda. Just the below 2 steps helped me resolve:

conda remove opencv
conda install -c conda-forge opencv=4.1.0

如果您使用的是pip,则可以尝试

If you are using pip, you can try

pip install opencv-contrib-python

这篇关于OpenCV错误:该功能未实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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