Python opencv 未接收摄像头信号

发布于 2024-12-05 09:07:50 字数 1051 浏览 0 评论 0原文

我一直在尝试使用 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 技术交流群。

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

发布评论

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

评论(1

你げ笑在眉眼 2024-12-12 09:07:50

我是 SimpleCV 开发人员之一。看来您正在尝试使用标准 python openCV 包装器。

我建议做的就是运行这里的示例:
https://github.com/sightmachine/SimpleCV/blob /develop/SimpleCV/examples/display/simplecam.py

或者这里也是代码:

import time, webbrowser
from SimpleCV import *

#create JPEG streamers
js = JpegStreamer(8080)
cam = Camera()

cam.getImage().save(js)
webbrowser.open("http://localhost:8080", 2)

while (1):
  i = cam.getImage()
  i.save(js)
  time.sleep(0.01) #yield to the webserver

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:

import time, webbrowser
from SimpleCV import *

#create JPEG streamers
js = JpegStreamer(8080)
cam = Camera()

cam.getImage().save(js)
webbrowser.open("http://localhost:8080", 2)

while (1):
  i = cam.getImage()
  i.save(js)
  time.sleep(0.01) #yield to the webserver
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文