paroj / libraw.py

Python Bindings for libraw
GNU Lesser General Public License v2.1
20 stars 4 forks source link

seg fault with raw_image #1

Closed ceyzeriat closed 8 years ago

ceyzeriat commented 8 years ago

Hi,

In case I want to access straight to the data contained in a raw file: dummy = rawpy.imread('myimage.NEF').raw_image I have a segmentation fault, and python crashes.

I tried without success: dummy = rawpy.imread('myimage.NEF').raw_image.copy()

Doing it in 2 steps works fine: dummy = rawpy.imread('myimage.NEF') dummy = dummy.raw_image

So my solution now is to create a loading function: def loadraw(im): dummy = rawpy.imread(im) return dummy.raw_image.copy()

Not too much of a big issue for me, but I thought you my want to have a look :-)

BTW, is there any way to include reading the EXIF data of a file in rawpy?

Cheers, and thanks a lot for that very nice library ! G

paroj commented 8 years ago

you actually want to post it here: https://github.com/neothemachine/rawpy

SamWhited commented 8 years ago

At the risk of sounding spammy, you might also try rawkit, which this library was originally based on. It may not have the same problem (or it may, in which case we'd love to fix it).

ceyzeriat commented 8 years ago

Hi SamWhited. I installed it but couldn't find a way to get to the raw values of each photosite as a numpy.array from rawkit library.

paroj commented 8 years ago

In case anybody wants wants to use the code from this project, you can get a numpy array like:

proc = libraw.LibRaw()     # create RAW processor
proc.open_file("file.dng") # open file
proc.unpack()              # extract mosaic from file
np_array = proc.imgdata.rawdata.raw_image
SamWhited commented 8 years ago

There is also a PR in the works (which I will merge soon hopefully, been busy) that will add this to the higher level APIs so that you don't have to dig down into libraw land and can take advantage of the automatic memory management and what not that rawkit provides. See: photoshell/rawkit#104

If you notice any of these issues in rawkit/libraw let us know. I'd love to figure out what the differences are, and contribute the fix back to this project if possible since we both started from Cameron's same snippet, IIRC.

ceyzeriat commented 8 years ago

Thanks paroj & SamWhited. I had seen the unpack() method and my CPUs burning but couldn't figure out where the data landed! I indeed "only" need to get to the raw data and photosite colors in order to make 4 maps (1 for each RGBG) and then apply my own weird astronomy processings! I'll keep an ear up when you've merged. Cheers