【发布时间】:2012-12-05 20:58:24
【问题描述】:
我正在寻找一种将网络摄像头集成到我的 python 程序中的方法。
我在 Raspberry Pi A 型超频至 900mHz 上运行,因此该解决方案需要与 ARM 兼容并且(希望)是轻量级的。
我看到的大多数帖子都建议使用 OpenCV 模块来读取网络摄像头,但我无法从我的网络摄像头中看到一个黑框。我假设 OpenCV 与我的网络摄像头不兼容。但是,可用于 linux 的所有其他网络摄像头应用程序都可以检测并显示来自我的网络摄像头的提要。
我想知道是否有任何其他轻量级或简单的方法可以使用 python 从我的网络摄像头捕获。也许我可以直接与 /dev/ 下为我的网络摄像头出现的 video0 设备交互?我愿意接受任何建议;因为我现在正在做的,是行不通的。
谢谢
(根据要求):
v4l2-ctl --all 的输出:
Driver Info (not using libv4l2):
Driver name : uvcvideo
Card type : UVC Camera (046d:081b)
Bus info : usb-bcm2708_usb-1.2
Driver version: 3.2.27
Capabilities : 0x04000001
Video Capture
Streaming
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'YUYV'
Field : None
Bytes per Line: 1280
Size Image : 614400
Colorspace : SRGB
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 640, Height 480
Default : Left 0, Top 0, Width 640, Height 480
Pixel Aspect: 1/1
Video input : 0 (Camera 1: ok)
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 30.000 (30/1)
Read buffers : 0
这是我正在使用的代码 sn-p:
import cv
cv.NamedWindow("camera", 1)
capture = cv.CaptureFromCAM(0)
while True:
img = cv.QueryFrame(capture)
cv.ShowImage("camera", img)
if cv.WaitKey(10) == 27:
break
cv.DestroyWindow("camera")
感谢您的帮助!
【问题讨论】:
-
请发布
v4l2-ctl --all和一些您现在正在使用的代码。 -
我已将它添加到我的开篇文章中。谢谢!
标签: python opencv webcam raspberry-pi