1

In python module picamera, does anyone noticed that camera.capture(array, 'rgb') is quite slow?? If you try to measure this time is about 540ms...

example code (the "real code" is irrelevant):

from picamera import PiCamera
import numpy as np
from time import sleep

camera = PiCamera()
camera.resolution = (320, 240)
camera.framerate = 24
time.sleep(2)
output = np.empty((240, 320, 3), dtype=np.uint8)
camera.capture(output, 'rgb')

Then I use the output object to render a QWidget There is a faster way to do it?? I want something to about 16ms latency.

rebellion
  • 51
  • 1
  • 8
  • Related https://raspberrypi.stackexchange.com/a/24259/19949 https://raspberrypi.stackexchange.com/a/32954/19949 and https://raspberrypi.stackexchange.com/a/58941/19949 – Ghanima Aug 01 '18 at 21:50
  • Could you please edit your question to include your code or command you used to write the pictures? The Raspberry PI usb system is notoriously slow. – NomadMaker Aug 01 '18 at 22:56
  • At the moment i can't write the complete code, I'll update as soon I'll reach my workstation.. – rebellion Aug 02 '18 at 06:04

1 Answers1

1

Finally, I've managed to do it, basically, I have used the underlying MMAL object to get the input directly. Now I have maximum framerate while rendering of 45ms, which is almost real-time for my needs. I think it's possible to go lower by changing the format.

from picamera import mmal, mmalobj as mo
from time import sleep


def image_callback(port, buf):
    print(buf.data)
    return False

camera = mo.MMALCamera()
preview = mo.MMALRenderer()

camera.outputs[0].framesize = (320, 160)
camera.outputs[0].framerate = 30
camera.outputs[0].format = mmal.MMAL_ENCODING_RGB24
camera.outputs[0].commit()

camera.outputs[0].enable(image_callback)

sleep (10)

camera.outputs[0].disable()

usefull link: https://picamera.readthedocs.io/en/release-1.13/api_mmalobj.html

rebellion
  • 51
  • 1
  • 8