limited framerate picamera v2

两盒软妹~` 提交于 2020-01-24 19:36:08

问题


Question about framerates on the picamera v2: According to the documentation of picamera , the following framerates are feasible for this hardware:

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

However, when gathering images with the capture_sequence method (which in the documentation is referred to as the fastest method) I don't get close to these numbers.

For the 1280x720 rate it maxes out at 25 fps, at 640x480 it maxes out close to 60.

The calculations I'm performing are irrelevant i.e. commenting them out doesn't make a difference (calculations are fast enough to not be the cause of the issue). If somebody would see some flaws in what I'm try to do and would solve increasing the framerate ... .

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)))

thanks in advance

来源:https://stackoverflow.com/questions/38512677/limited-framerate-picamera-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!