Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seg fault with raw_image #1

Closed
ceyzeriat opened this issue Nov 9, 2015 · 6 comments
Closed

seg fault with raw_image #1

ceyzeriat opened this issue Nov 9, 2015 · 6 comments

Comments

@ceyzeriat
Copy link

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
Copy link
Owner

paroj commented Nov 9, 2015

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

@paroj paroj closed this as completed Nov 9, 2015
@SamWhited
Copy link

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
Copy link
Author

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
Copy link
Owner

paroj commented Nov 10, 2015

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
Copy link

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants