VideoCapture:捕获图形错误

发布于 2024-11-05 15:05:22 字数 291 浏览 4 评论 0原文

我使用 Python (2.7) 包 VideoCapture。当我尝试实例化设备时,出现异常:

错误:无法创建捕获图。

我使用 cam = Device(),所以没有什么特别的。我有一台笔记本电脑,可以正常工作,而另一台笔记本电脑却出现异常。它们有所不同,但都有内置 USB 网络摄像头。

一周前它有效,但现在我只得到例外。两者都使用 Windows 7。

有谁知道如何解决这个问题,或者我如何获得更多信息出了什么问题?

谢谢。

I use the Python (2.7) package VideoCapture. When I try to instantiate the Device, I get an Exception:

Error: Capture Graph could not be created.

I use cam = Device(), so nothing special there. I have one laptop where this works without a problem, and another where I get the Exception. They are different, but both have internal USB-Webcams.

One week ago it worked, but now I only get the exception. Both use Windows 7.

Does anybody have an idea how to resolve this, or how I could get more information what is wrong?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

枉心 2024-11-12 15:05:22

我认为出现此错误的原因有多种。

我第一次遇到它是因为我同时运行了另一个程序。关闭其他程序解决了该问题。

我第二次遇到这个问题是当我尝试同时使用两个摄像头,只是尝试立体视觉时。为了解决这个问题,我在两次捕获之间添加了延迟,然后我就可以运行它了。

import time
from VideoCapture import Device

cam0 = Device(0)
cam1 = Device(1)

for i in xrange(30):
    cam0.saveSnapshot('video/image0_%d.jpg' % i, timestamp=1)
    time.sleep(0.05)
    cam1.saveSnapshot('video/image1_%d.jpg' % i, timestamp=1)
    time.sleep(0.1)

我认为此错误的原因(以及为什么您可能在其他笔记本电脑上没有遇到它)是某些驱动程序似乎不能很好地处理同时访问。当您尝试快速连续地从设备驱动程序获取数据时,一些锁定不足的数据结构会变得混乱。

I think this error can appear for a variety of reasons.

The first time I encountered it, it was because I had another run of the program going at the same time. Closing the other program solved the issue.

The second time I ran into it was when I was trying to use two cameras at the same time, just experimenting with stereo vision. In order to get around this, I added a delay between the two captures and I could run it.

import time
from VideoCapture import Device

cam0 = Device(0)
cam1 = Device(1)

for i in xrange(30):
    cam0.saveSnapshot('video/image0_%d.jpg' % i, timestamp=1)
    time.sleep(0.05)
    cam1.saveSnapshot('video/image1_%d.jpg' % i, timestamp=1)
    time.sleep(0.1)

I think the reason for this error (and why you might not have encountered it on your other laptop), is that some drivers don't seem to handle simultaneous access very well. When you try to get data from the device drivers in rapid succession, some data structures that have insufficient locking get messed up.

双马尾 2024-11-12 15:05:22

我知道这是一个非常古老的线程。第二次实例化设备后,我不断收到此错误。将代码移至主线程解决了我的问题。

I know this is a really old thread. I kept getting this error after instantiating the Device a second time. Moving the code to the main thread fixed the problem for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文