使用Python的低FPS,Raspberry Pi上的OpenCV

时间:2015-06-17 12:57:41

标签: python opencv raspberry-pi frame-rate

我正在尝试使用Python和OpenCV对Raspberry Pi进行一些图像处理。到目前为止,除了较低的FPS率外,它运行良好。即使没有任何图像处理,只需使用下面的代码,我只得到10 FPS 640x480分辨率。 有更快的方式来捕获视频流吗?我这里有什么问题吗?

import numpy as np
import cv2
import time
from picamera.array import PiRGBArray
from picamera import PiCamera

# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
camera.resolution = (640, 480)
camera.framerate = 32
rawCapture = PiRGBArray(camera, size=(640, 480))
# allow the camera to warmup
time.sleep(0.1)
start = time.time()

for img in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):

    frame = img.array
    rawCapture.truncate(0)
    end = time.time()
    print 'fps:', int(round(1 / (end - start)))
    start = time.time()

到目前为止,谢谢你。

问候

1 个答案:

答案 0 :(得分:0)

From the best of my knowledge, the hardware always produces YUV (I420) and conversion to BGR or RGB is done as an extra vector sw stage, thus reducing your frames per second.

I would suggest creating a thread dedicated solely to your IO pipeline, reducing latency and potentially increasing your fps, however I highly doubt you will be able to achieve the glorious 90fps (at 640x480) with the BGR model.

Check these two posts for a more detailed explanation: limited framerate picamera v2

https://raspberrypi.stackexchange.com/questions/22040/take-images-in-a-short-time-using-the-raspberry-pi-camera-module