繁体   English   中英

在Raspberry Pi上使用Python和OpenCV实现低FPS

[英]Low FPS with Python, OpenCV on Raspberry Pi

我正在尝试使用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()

到目前为止谢谢你。

问候

据我所知,硬件始终会产生YUV (I420),并作为额外的矢量sw阶段完成向BGR或RGB的转换,从而减少了每秒的帧数。

我建议创建一个专门用于您的IO管道的线程,以减少延迟并可能提高fps,但是我非常怀疑您是否能够使用BGR模型实现出色的90fp​​s(640x480)。

检查这两个帖子以获取更详细的解释: 有限帧率picamera v2

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM