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

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

问题描述

我正在尝试让 OpenCV 在我的 Ubuntu 机器上使用 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) with error: cv2.error: OpenCV(3.4.2). 函数没有实现.).我正在使用蟒蛇.只是以下 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天全站免登陆