0

I am writing a script in Python for continuous long exposure image recording that saves n images into the buffer as shown:

outputs = [io.BytesIO() for i in range(0, n)]
camera.capture_sequence(outputs, format="jpeg", use_video_port=True)

Later, I save the images as jpg:

for i in range(0, n):
    buf = outputs[i]
    buf.seek(0)
    with open(filename, "wb+") as f:
        if args.v:
            print("Save file: {}".format(filename))
            f.write(buf.read())

I would like to access the buffer directly without saving images. I tried numpy frombuffer and fromstring; however, it was messing with jpg coding. How could I access outputs directly as numpy array with shape (n, W, H, CH), where W and H are width and height and CH is a color channel?

1
  • It is far from clear what you are proposing, but whatever it is it is not Pi specific. I have done image processing (in c) and it is not difficult but attempting to operate on jpg directly is futile. Depending on number of images and size you need to decode into pixels which can be all at once or sequentially.
    – Milliways
    Jun 27, 2021 at 5:14

0

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.