Python中的Webcam DirectShow属性页 [英] Webcam DirectShow Properties Page in Python

查看:259
本文介绍了Python中的Webcam DirectShow属性页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows Python 2.7应用程序,该应用程序需要与许多不同的USB网络摄像头进行通信。我一直在使用OpenCV,但是对于某些科学型网络摄像头,未检测到默认帧速率,捕获格式等,因此我只能得到空白图像。可以打开DirectShow属性页的外部程序可以在我的程序中解决此问题,但是我希望在应用程序中具有此功能。

I'm working on a windows Python 2.7 application that needs to communicate with many different USB webcams. I have been using OpenCV, but for some scientific webcams, the default frame rate, capture format, etc. aren't detected and I get only a blank image. An external program that can open DirectShow properties pages can fix this in my program, but I'd like to have this feature in my application.

我尝试了一个可用的Python库来执行此操作:VideoCapture(http://videocapture.sourceforge.net/)。虽然这会打开属性页,但不允许更改任何设备设置(错误连接...此格式当前不可用,但是AMCAP可以使用)。我想知道基础代码是否已经过时。

I have tried one available Python library to do this: VideoCapture (http://videocapture.sourceforge.net/). While this opens property pages, it doesn't allow changing any device settings ("Error Connecting... This format is not currently available", but AMCAP works). I'm wondering if the underlying code is too out of date.

在VideoCapture或videoInput(http://www.muonics.net/school / spring05 / videoInput /)并不是很有帮助,因为它们都依赖于散布在众多旧的特定DirectX / WindowsSDK软件包中的旧库。不幸的是,我没有足够的知识或时间重新开始或了解VideoCapture的问题。

Playing with the C++ code in VideoCapture or videoInput (http://www.muonics.net/school/spring05/videoInput/) isn't very helpful since they both rely on old libraries spread across numerous old, specific DirectX/WindowsSDK packages. Unfortunately, I don't have the knowledge or time to start from scratch or to figure out what's wrong with VideoCapture.

是否有另一个已经在组装的Python程序包可以做这个?我一直在寻找一小会儿。我稍微看了libvlc python绑定(因为VLC可以访问属性页)和DirectPython,但我不清楚它们是否具有我想要的东西。

Is there another already assembled Python package out there that can do this? I've been searching for a while now with little luck. I looked a little at libvlc python bindings (since VLC can access the property pages) and DirectPython, but it isn't clear to me that these have what I'm looking for.

谢谢!

推荐答案

我也遇到了类似的问题。基本上,我不小心通过查看自己捕获的内容来修复它。

I had a similar sounding problem. Basically, I accidentally fixed it by wanting to see what I captured.

cap = cv2.VideoCapture(0)
print cap.read()      #once to inialize
print cap.read()      #twice to check that it actually initialized

第一个 .read()返回(False,None),而第二个实际上有提要。在添加此代码之前,我会将 None 传递给 cv2.imshow('title',frame),我的程序将崩溃。

The first .read() returns (False, None) while the second one actually has the feed. Before I added this I would pass None to cv2.imshow('title',frame) and my program would crash.

我不知道这是否可以解决您的问题。我的是DinoLite USB显微镜,我想我只是通过DirectX访问它。 OpenCV 2.4.8。

I don't know if this solves your problem. Mine is a DinoLite USB microscope and I think I'm just accessing it through DirectX. OpenCV 2.4.8.

这篇关于Python中的Webcam DirectShow属性页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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