I am useing next code for frame capture:

from picamera import PiCamera import utils

res = (1600,1600)
camera = PiCamera(resolution = res)
camera.resolution = res
camera.raw_format = 'rgb'
camera.framerate = 29
camera.iso = 800
camera.exposure_mode = 'off'
camera.meter_mode = 'backlit'
camera.image_effect = 'denoise'

def raw_frame():
    stream = io.BytesIO()
    camera.capture_sequence([stream,],format="jpeg", use_video_port=True)
    return stream

def decoded_frame(stream):
    return cv2.imdecode( np.fromstring(stream.getvalue(), dtype=np.uint8), 1)

def get_frame():
    return decoded_frame(raw_frame())

And the timings are

raw_frame - 0.187004089355s
decoded_frame - 0.481935024261s
get_frame - 0.670401096344s

Can anyone explain, from what exactly this time is come?

It takes almost 0.2s to get raw data from camera, that is 5fps, not ~30 as it should be. It can be ok, if the decoding will be fast, but I think it can't because of jpeg and image size.

If I use raw format, not jpeg, it takes almost a second to get the data. So, the question: is there any way to speedup the decoding, or to speed up capturing process? 1s for frame capture is too long.

  • Your sd card write speed may be a big factor in this – Mohammad Ali Aug 27 '16 at 16:56
  • I do not write frames on SD card. Just recieving and in-memory processing. – Дмитрий Пузырьков Aug 28 '16 at 18:37
  • Well like wherever you are writing to may be slowing you down, but also if you are running on the Pi 3 you may be able to rewrite your application to be multi threaded to make use of all the cup cores. But other that that the only thing that I can think of would be the gpu cpu memory split – Mohammad Ali Aug 28 '16 at 18:40
  • For comparison I wrote a simple wrapper over raspicam library (github.com/cedricve/raspicam), and it performance is much better: ~0.01s per frame ( grayscale, numpy array). I think this is the Python performance itself is giving such delay. – Дмитрий Пузырьков Aug 28 '16 at 18:45
  • By the way, PI 3 is doing beter, but not much. I can give the numbers if you interested. – Дмитрий Пузырьков Aug 28 '16 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.