Python opencv 未接收摄像头信号
我一直在尝试使用 SimpleCV (www.simplecv.org) 模块来运行图像识别和操作。不幸的是,我传入的视频非常挑剔,我不确定我做错了什么。仅使用一些基本示例代码:
import cvwindow = cv.NamedWindow("camera", 1)
capture = cv.CreateCameraCapture(0)
width = int(cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_WIDTH))
height = int(cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_HEIGHT))
while 1:
img = cv.QueryFrame(capture)
cv.ShowImage("camera", img)
k = cv.WaitKey(1)
if(k == 102):
cv.destroyWindow("camera")
break
当我插入 Logitech Webcam 500 时,它可以正常工作。但是,当我尝试使用 Vimicro Altair 摄像头时,出现灰屏,并且在保存到文件时,文件为空。
我还尝试使用 SimpleCV 代码,基于他们的 cookbook< /a> 的思路是:
mycam = Camera()
img = mycam.getImage()
同样不成功,但不是返回任何数据,而是返回一个全黑的图像。
我对造成这种情况的原因感到非常困惑,我在笔记本电脑上尝试了完全相同的系统,但它甚至无法从罗技摄像头获取图像。我正在运行带有 Python 2.7 和 SimpleCV 1.1 的 Windows 7 64 位。
谢谢
I've been trying to use the SimpleCV (www.simplecv.org) module to run image recognition and manipulation. Unfortunately, my incoming video feed has been quite finicky, and I'm not sure what I did wrong. Just using some basic sample code:
import cvwindow = cv.NamedWindow("camera", 1)
capture = cv.CreateCameraCapture(0)
width = int(cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_WIDTH))
height = int(cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_HEIGHT))
while 1:
img = cv.QueryFrame(capture)
cv.ShowImage("camera", img)
k = cv.WaitKey(1)
if(k == 102):
cv.destroyWindow("camera")
break
Which works perfectly when I plug in my Logitech Webcam 500. However, when I attempt to use my Vimicro Altair camera, I get a grey screen, and when saving to file, the file is empty.
I also attempted to use SimpleCV code, based off their cookbook along the lines of:
mycam = Camera()
img = mycam.getImage()
which was equally unsuccessful, however instead of returning no data, simply returned an image that was completely black.
I'm at quite a loss of what is causing this, I tried the exact same system on my laptop, which failed to even get an image from the Logitech cam. I'm running Windows 7 64-bit with Python 2.7 and SimpleCV 1.1.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我是 SimpleCV 开发人员之一。看来您正在尝试使用标准 python openCV 包装器。
我建议做的就是运行这里的示例:
https://github.com/sightmachine/SimpleCV/blob /develop/SimpleCV/examples/display/simplecam.py
或者这里也是代码:
I'm one of the SimpleCV developers. It appears you are trying to use the standard python openCV wrapper.
What I recommend doing is just run the example here:
https://github.com/sightmachine/SimpleCV/blob/develop/SimpleCV/examples/display/simplecam.py
Or here is the code as well: