VideoCapture: Capture Graph Error

随声附和 提交于 2019-12-24 10:18:19

问题


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.


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/5911382/videocapture-capture-graph-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!