access read / write violation with ctypes
digitalhillbilly at hotmail.com
Thu Aug 6 03:40:57 CEST 2009
I'm quite new to cytpes and am having some troubles I was hoping I
could get a little help with. Before I get into the details this is
what I'm trying to accomplish - I would like to read a dng with python
pass it through either libraw.dll or dcraw.dll (notes on dcraw.dll
version at the end) for initial processing then to MagickWand for some
light enhancement and final jpeg output. After I get these working I
will see how I can add LittleCMS into the fray. I'm not doing
something correctly but don't know what. I've read a lot of documents
over the past couple days and though I've learned quite a lot I just
can't get past this access violation error.
I very grateful for anything that can be offered.
I am currently working out MagickWand and dcraw separately but am
having similar troubles with both resulting in either 'Windows Error:
exception: access violation reading 0x00000000' or alternatively
'Windows Error: ... writing'
1 - MagickWand (read violation):
I'm using popen to capture dcraw stdout and want to pass it to
magickwand. If I instead write the dcraw output to a file then read it
with magickwand I get the same error. But if I comment out the dcraw
protion and read the dcraw output file from the previous attempt,
MagickWand opens the file fine and I can manipulate it to my hearts
content. The basics:
proc = subprocess.Popen("dcraw -c -4 -T image.dng", shell=True,
magickWandLib = 'C:\\Program Files (x86)\\ImageMagick-6.5.3-Q16\
Magick = cdll.LoadLibrary(magickWandLib)
wand = Magick.NewMagickWand()
-> access violation reading
2 - DCRaw (write violation):
I've been bouncing between libraw.dll and dcraw.dll. The dcraw version
I'm using is found at
. Libraw is limited in the sence that it is mainly suited to loading
and unpacking raw images. Actual processing is done only in emulation
mode which I have not yet been able to access throught the library.
PerfectRaw uses a tweaked and librarised version of dcraw with thier
GUI + some enhanced functions. I'm only interesed in the dll though
2.1 - libraw.dll
I won't go into great detail as I can get it to work but only open,
unpack and write out a tiff or ppm. No process settings
2.2 - dcraw.dll
I can load the library but cannot initialise an instance. Each attempt
in a variety or methods always returns an 'access violation writing
0x00000000'. The parameters I use to initialise are taken from a test
program provided by the authors.
printf("Resultado de leer el RAW: %i\n",DCRAW_Init("c:\\test\
dcraw_lib = 'C:\\programs\\PerfectRaw\\dcraw.dll'
dcraw = ctypes.cdll.LoadLibrary(dcraw_lib)
img = 'C:\\programs\\PerfectRaw\\image.dng'
dcraw.DCRAW_Init(img,4000,3000) # canon G9 converted to dng
-> access violation writing
More information about the Python-list