有限帧率picamera v2

时间:2016-07-21 19:19:55

标签: python-2.7 frame-rate raspberry-pi3

有关picamera v2的帧率的问题: 根据{{​​3}}的文档,以下帧速率对于此硬件是可行的:

Resolution  Aspect Ratio    Framerates  Video   Image   FoV     Binning
1   1920x1080   16:9    0.1-30fps   x       Partial     None
2   3280x2464   4:3     0.1-15fps   x   x   Full    None
3   3280x2464   4:3     0.1-15fps   x   x   Full    None
4   1640x1232   4:3     0.1-40fps   x       Full    2x2
5   1640x922    16:9    0.1-40fps   x       Full    2x2
6   1280x720    16:9    40-90fps    x       Partial     2x2
7   640x480     4:3     40-90fps    x       Partial     2x2

但是,使用capture_sequence方法(在文档中称为最快的方法)收集图像时,我并没有接近这些数字。

对于1280x720的速率,最大速率为25 fps,在640x480时最高可接近60 fps。

我正在执行的计算是无关紧要的,即对它们进行评论并没有什么区别(计算速度足够快,不会成为问题的原因)。 如果有人会在我尝试做的事情上看到一些缺陷并且会解决增加帧速率......

import io
import time
import picamera
#import multiprocessing
from multiprocessing.pool import ThreadPool
#import threading
import cv2
#from PIL import Image
from referenceimage import ReferenceImage
from detectobject_stream import detectobject_stream
from collections import deque
from datawriter import DataWriter


backgroundimage=ReferenceImage()
threadn = cv2.getNumberOfCPUs()
pool = ThreadPool(processes = threadn)
pending = deque()
Numberofimages=500

starttime=time.time()

#datawrite=DataWriter()
#datawrite.start()

def outputs():
    stream = io.BytesIO()
    Start=True
    global backgroundimage
    for i in range(Numberofimages):
        yield stream

        #print time.time()-starttime
        #start = time.time()
        while len(pending) > 0 and pending[0].ready():
            timestamps = pending.popleft().get()
            #print timestamps   

        if len(pending)<threadn:
            stream.seek(0)
            task = pool.apply_async(detectobject_stream, (stream.getvalue(),backgroundimage,Start,0))
        pending.append(task)   

        Start=False

        stoptime = time.time()

        print stoptime-start

        stream.seek(0)
        stream.truncate()
        #print i

with picamera.PiCamera() as camera:
    #camera.resolution = (640, 480)
    camera.resolution = (1280, 720)
    camera.framerate = 60
    camera.start_preview()

    time.sleep(2)
    start = time.time()
    camera.capture_sequence(outputs(),format='bgr',use_video_port=True)
    finish = time.time()
    print('Captured images at %.2ffps' % (Numberofimages / (finish - start)))

提前致谢

0 个答案:

没有答案