1

I acquired a set of images with the command raspistill -r -ss 100000 -o image.jpg, and I'd like to process the 'JPEG+RAW' images, which I already obtained, with OpenCV on python. I am aware of discussions such as this one, but I was wandering if there is a simple script to get the image in numpy array form in a direct way.

Eggman
  • 45
  • 7
  • Hello and welcome. Possibly related https://raspberrypi.stackexchange.com/q/87639/19949 https://raspberrypi.stackexchange.com/q/50862/19949 https://raspberrypi.stackexchange.com/q/47782/19949 https://raspberrypi.stackexchange.com/q/75209/19949 https://raspberrypi.stackexchange.com/q/72860/19949 Especially the last question addresses the reading of the Camera to a numpy array. – Ghanima Oct 02 '18 at 16:49

1 Answers1

1

My team just released a library for this:

https://github.com/OsmoSystems/picamraw/

Example usage:

from picamraw import PiRawBayer, PiCameraVersion

raw_bayer = PiRawBayer(
    filepath='/path/to/image.jpeg',  # your JPEG+RAW file
    camera_version=PiCameraVersion.V2,
)

raw_bayer.to_rgb()  # Numpy array that you can feed to OpenCV, pyplot.imshow(), etc.

Note: the conversion from RAW to RGB is actually not trivial. Our implementation is as straightforward as possible (with the aim of being true to the RAW data as much as possible) but there are much more complex demosaicing algorithms which may be what you want depending on your use case.

waterproof
  • 203
  • 1
  • 9
  • Thank you, in the end I did use 6by9's modified dcraw to extract tiffs (https://github.com/6by9/dcraw), this seems simpler and faster, I will try it out. – Eggman Dec 06 '18 at 08:36