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.
-
Hello and welcome. Possibly related raspberrypi.stackexchange.com/q/87639/19949 raspberrypi.stackexchange.com/q/50862/19949 raspberrypi.stackexchange.com/q/47782/19949 raspberrypi.stackexchange.com/q/75209/19949 raspberrypi.stackexchange.com/q/72860/19949 Especially the last question addresses the reading of the Camera to a numpy array.– Ghanima ♦Commented Oct 2, 2018 at 16:49
Add a comment
|
1 Answer
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.
-
Thank you, in the end I did use 6by9's modified dcraw to extract tiffs (github.com/6by9/dcraw), this seems simpler and faster, I will try it out.– EggmanCommented Dec 6, 2018 at 8:36