使用python高效访问网络摄像头和管道流到设备驱动程序

时间:2013-08-06 18:04:01

标签: python opencv webcam linux-device-driver performance

我需要将我的摄像头流传输到运行ubuntu的ARM上的设备驱动程序。现在我想知道是否可以在python中做到这一点更有效。我首先访问每个元素并使用.open()。但真的没有效果。现在我只运行该程序并将其传递给设备驱动程序(或文件)。但我想知道我是否可以用python更高效?我不认为这会使用此代码在我的手臂处理器上给我25fps。我跑了几个测试,只得到7fps。

#!/usr/bin/python
import cv 
import sys
import os

camera_index = 1
capture = cv.CaptureFromCAM(camera_index)
def repeat():
    global capture
    global camera_index
    global count
    frame = cv.GetMat(cv.QueryFrame(capture))
    framegray = cv.CreateMat(480, 640, cv.CV_8UC1)
    cv.CvtColor(frame, framegray, cv.CV_BGR2GRAY)
    sys.stdout.write(framegray.tostring())
    #cv.ShowImage("Webcam", framegray)
    c = cv.WaitKey(40)
    #pipe_out.close()
    if c == 27:
        sys.exit()
    #waitkey kan executitijd van bv dingen ervoor aftrekken


while True:
    repeat()

0 个答案:

没有答案