Finally, I've buildt it. If somebody else is interested in building the thread-safe library using MinGW, here the Makefile (for v. 0.11.3). It works fine.
Thanks for your help,
Davide
Luminance HDR Developer
--------------------------------------
all: library samples
# OpenMP support
#OPENMP_CFLAGS=-fopenmp
#NO_THREADS=-DLIBRAW_NOTHREADS
# LCMS support
#LCMS_DEF=-DUSE_LCMS -I/usr/local/include
#LCMS_LIB=-L/usr/local/lib -llcms
for gcc compiler, -pthread is for generating thread-safe code. At least, it should
- define _REENTRANT, so many #includes will change behaviour
- link with thread-safe C runtime
I'm not sure that MinGW has multi-thread safe runtime.
Unfortunately, the static build made by MinGW (I did it already) of the thread-safe library (libraw_r) gives me exactly the same error during the linking. I'll try with the one included in your link this evening and I'll let you know.
You can integrate C-code in MATLAB using the mex-API. I looked at this for dcraw, but got stuck, and I found that it was simply less work to make a thin MATLAB wrapper calling dcraw from the command-line.
I remember some frustrating aspects of doing anything to the dcraw code, hope that this project makes it easier.
LibRaw (and, so, dcraw_emu) contains 'auto-maximum' feature to deal with 'pink clouds' problem.
If you want to produce files which are binary identical to dcraw's results, you should switch this option off. Use -c 0 switch of dcraw_emu to do that.
So, if your code crashes in ::free(), it should crash in LibRaw's free() too. For pointer allocated by ::malloc() there is no difference between LibRaw::free() and ::free().
I cannot reproduce this problem in my Windows enviroment (VS2008 SP1, Win7/x64).
Could you please describe your enviroment in more detail (VS2008 patch level, Windows version, may be sample code)?
P.S. Sorry for very aggressive captcha. This is the only way to prevent forum/comments spam.
Please note, that registered/authorized users are not terrorized by captcha :)
I also encounter this problem.
In my project I link the libraw (I use Visual Studio). Everything works fine.
However if I want to free (using ::free(ptr)) the pointer returned by dcraw_make_mem_image(...) I get an exception
_CrtIsValiHeapPointer(pUserData) documented in dbgheap.c with
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
I think the problem is caused that the lib is creating the memory, so only the lib itself is allowed to free it afterwards. The application does only seem to have rights to read the memory.
If I also make the free function public in class LibRaw it seems to work, but there should be a more elegant solution ;)
Good evening Dan!
I'm a moderator of Russian CG Forum Arttower.ru. Could you give us the permisson to publish the Russian translation of this article (http://www.libraw.su/articles/raw-module.html) on our site?
As for profiles. There is not a profile as such. You need to determine your own cameras RGB to XYZ response. If you have a D70s I could send you some matrixes that I made earlier. I am in the process of publishing a paper on the subject. Ill keep you posted.
I successfully applied CIECAM02 to a RAW imaging workflow. The main problem was to identify the adopted white from scene colorimerty as an input to CIECAM02. I ended up using the cameras white balance for ease in order to complete the experiment. The scene illumination was calculated from ISO and Exposure and gave favorable results. The main part of the process was to characterise the camera using a double monochromator and calculate the cameras spectral response. This was then used to determine the device RGB to XYZ matrix by reducing errors in JMH space for different values of La and white point.
The resulting matrices were used to transform RAW RGB to XYZ according to scene white and La and then passed through CIECAM02.
The internal coordinates used were JMH and output to standard sRGB viewing conditions through the reverse CIECAM02.
I got some pretty good results, (although maybe not appearance perfect) compared to the sRGB JPEG produced by the Nikon D70s.
The problem is in MacOS X fseek() call. It takes 32-bit offset (long int). There is fseeko() function which takes off_t offset and so will work with files larger than 2Gb.
The quick fix:
in libraw/libraw_datastream.h change:
return substream?substream->seek(o,whence):fseek(f,o,whence);
to
return substream?substream->seek(o,whence):fseeko(f,o,whence);
This will break compatibility with Windows (no fseeko) and, possible, Linux. I'll prepare more universal solution (with #ifdef) today or tomorrow (to appear in 0.8-Beta5)
1. Frame offset is stored as 64 bit in this format, so there is no *theoretical* problems.
2. There is two possible sources of problems under Mac OS X:
a) one possible source is 32-bit off_t type (i.e. some special compilation flags are needed because 64-bit offsets are possible)
b) FILE * interface under Mac OS X does not support large files.
I've MacBook with MacOS 10.5 on hands, so will continue investigations. Hope, I'll find problem source today.
Finally, I've buildt it. If somebody else is interested in building the thread-safe library using MinGW, here the Makefile (for v. 0.11.3). It works fine.
Thanks for your help,
Davide
Luminance HDR Developer
--------------------------------------
all: library samples
# OpenMP support
#OPENMP_CFLAGS=-fopenmp
#NO_THREADS=-DLIBRAW_NOTHREADS
# LCMS support
#LCMS_DEF=-DUSE_LCMS -I/usr/local/include
#LCMS_LIB=-L/usr/local/lib -llcms
# Common flags
# WARNING: library order matters
COMMON_LIBS=-lws2_32 -lm ${LCMS_LIB}
CLIBS=-L./lib -lraw_r ${COMMON_LIBS}
CFLAGS=-O3 -I. -w -DLIBRAW_NODLL ${OPENMP_CFLAGS} ${NO_THREADS} -lpthread -D_REENTRANT
DCRAW_LIB_OBJECTS=object/libraw_cxx.o object/libraw_c_api.o object/dcraw_common.o object/dcraw_fileio.o
library: lib/libraw_r.a
samples: bin/raw-identify bin/simple_dcraw bin/dcraw_emu bin/dcraw_half bin/mem_image bin/mem_image bin/unprocessed_raw bin/4channels
install: library
@if [ -d /usr/local/include ] ; then cp -R libraw /usr/local/include/ ; else echo 'no /usr/local/include' ; fi
@if [ -d /usr/local/lib ] ; then cp lib/libraw_r.a /usr/local/lib/ ; else echo 'no /usr/local/lib' ; fi
install-samples: samples
@if [ -d /usr/local/bin ] ; then cp bin/[a-z]* /usr/local/bin/ ; else echo 'no /usr/local/bin' ; fi
# Samples
bin/raw-identify: lib/libraw_r.a samples/raw-identify.cpp
g++ ${LCMS_DEF} ${CFLAGS} -o bin/raw-identify samples/raw-identify.cpp ${CLIBS}
bin/unprocessed_raw: lib/libraw_r.a samples/unprocessed_raw.cpp
g++ ${LCMS_DEF} ${CFLAGS} -o bin/unprocessed_raw samples/unprocessed_raw.cpp ${CLIBS}
bin/4channels: lib/libraw_r.a samples/4channels.cpp
g++ ${LCMS_DEF} ${CFLAGS} -o bin/4channels samples/4channels.cpp ${CLIBS}
bin/simple_dcraw: lib/libraw_r.a samples/simple_dcraw.cpp
g++ ${LCMS_DEF} ${CFLAGS} -o bin/simple_dcraw samples/simple_dcraw.cpp ${CLIBS}
bin/mem_image: lib/libraw_r.a samples/mem_image.cpp
g++ ${LCMS_DEF} ${CFLAGS} -o bin/mem_image samples/mem_image.cpp ${CLIBS}
bin/dcraw_half: lib/libraw_r.a object/dcraw_half.o
gcc ${LCMS_DEF} ${CFLAGS} -o bin/dcraw_half object/dcraw_half.o ${CLIBS} -lstdc++
bin/dcraw_emu: lib/libraw_r.a samples/dcraw_emu.cpp
g++ ${LCMS_DEF} ${CFLAGS} -o bin/dcraw_emu samples/dcraw_emu.cpp ${CLIBS}
#Libraries
# Non-threaded library
object/dcraw_common.o: internal/dcraw_common.cpp
g++ -c ${LCMS_DEF} ${CFLAGS} -o object/dcraw_common.o internal/dcraw_common.cpp
object/dcraw_fileio.o: internal/dcraw_fileio.cpp
g++ -c ${LCMS_DEF} ${CFLAGS} -o object/dcraw_fileio.o internal/dcraw_fileio.cpp
object/libraw_cxx.o: src/libraw_cxx.cpp
g++ -c ${LCMS_DEF} ${CFLAGS} -o object/libraw_cxx.o src/libraw_cxx.cpp
object/libraw_c_api.o: src/libraw_c_api.cpp
g++ -c ${LCMS_DEF} ${CFLAGS} -o object/libraw_c_api.o src/libraw_c_api.cpp
object/dcraw_half.o: samples/dcraw_half.c
gcc -c ${LCMS_DEF} ${CFLAGS} -o object/dcraw_half.o samples/dcraw_half.c
lib/libraw_r.a: ${DCRAW_LIB_OBJECTS}
-rm -f lib\\libraw_r.a
ar crv lib/libraw_r.a ${DCRAW_LIB_OBJECTS}
ranlib lib/libraw_r.a
# Clean
clean:
rm -f bin\\*.dSYM
rm -f lib\\lib*.a bin\\*.exe object\\*.o
for gcc compiler, -pthread is for generating thread-safe code. At least, it should
- define _REENTRANT, so many #includes will change behaviour
- link with thread-safe C runtime
I'm not sure that MinGW has multi-thread safe runtime.
What does -pthread stays for? My compiler (GCC 4.4.0 on MinGW) says that it is a unrecognized option.
Oh,
MinGW library is compiled without thread-safeness. You may try:
1) Add -pthread to CFLAGS in Makefile.mingw
2) Remove -DLIBRAW_NOTHREADS from all compilation rules.
I've added it to TODO for 0.12-Beta3 too
Unfortunately, the static build made by MinGW (I did it already) of the thread-safe library (libraw_r) gives me exactly the same error during the linking. I'll try with the one included in your link this evening and I'll let you know.
Thanks,
Davide
There are two different Win32 distributions of 0.11:
-Win32, compiled and linked by Visual Studio 2008
-Win32-MinGW - made by MinGW with gcc 4.4
These versions are not compatible.
MinGW version does not contain any .dll, only libraw.a for static linking.
You need either rebuild LibRaw from sources using mingw (mingw32-make -f Makefile.mingw) or download already built -MinGW version.
Direct link to 0.11.3/MinGW: http://www.libraw.org/data/LibRaw-0.11.3-Win32-MinGW.zip
Link to Rawnalyze backup copy: http://rawnalyze.rawtherapee.com/
Thanks for your patch.
It is integrated into LibRaw 0.11.3 and into coming LibRaw 0.12
You can integrate C-code in MATLAB using the mex-API. I looked at this for dcraw, but got stuck, and I found that it was simply less work to make a thin MATLAB wrapper calling dcraw from the command-line.
I remember some frustrating aspects of doing anything to the dcraw code, hope that this project makes it easier.
(the spam-filter here really hurts!)
Yes, output is converted to 8-bit only on file/memory writing stage (i.e. on output).
So, you may call dcraw_make_mem_image() to create 3-component 8-bit bitmap.
LibRaw (and, so, dcraw_emu) contains 'auto-maximum' feature to deal with 'pink clouds' problem.
If you want to produce files which are binary identical to dcraw's results, you should switch this option off. Use -c 0 switch of dcraw_emu to do that.
New versions of LibRaw are imported in KDE (libkdcraw) very fast. Usually in 1-2 days. So you just need to update your KDE extra libs from KDE trunk
The only real and easy solution is to write your files in .DNG format. Sure, there is no way to write CR2
Please see:
http://www.barrypearson.co.uk/articles/dng/specification.htm#areas
Using dng_validate or an EXIF metadata viewer should be able to tell you the resolutions of the various areas in your DNG file.
The libraw_memmgr::free() is very simple, it just calls upper level ::free than forgets the pointer:
So, if your code crashes in ::free(), it should crash in LibRaw's free() too. For pointer allocated by ::malloc() there is no difference between LibRaw::free() and ::free().
I cannot reproduce this problem in my Windows enviroment (VS2008 SP1, Win7/x64).
Could you please describe your enviroment in more detail (VS2008 patch level, Windows version, may be sample code)?
P.S. Sorry for very aggressive captcha. This is the only way to prevent forum/comments spam.
Please note, that registered/authorized users are not terrorized by captcha :)
I also encounter this problem.
In my project I link the libraw (I use Visual Studio). Everything works fine.
However if I want to free (using ::free(ptr)) the pointer returned by dcraw_make_mem_image(...) I get an exception
_CrtIsValiHeapPointer(pUserData) documented in dbgheap.c with
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
I think the problem is caused that the lib is creating the memory, so only the lib itself is allowed to free it afterwards. The application does only seem to have rights to read the memory.
If I also make the free function public in class LibRaw it seems to work, but there should be a more elegant solution ;)
Regards Tobias
Since LibRaw 0.9, the OpenMP pragmas are effective only on LibRaw compile time, not at apps compilation.
the image is allocated by 'upper level' (system) malloc, not LibRaw's one:
libraw_processed_image_t *ret = (libraw_processed_image_t*)::malloc(sizeof(libraw_processed_image_t)+ds);
So, it should be free-ed by system free(), not LibRaw::free();
Please describe your enviroment in more details.
Good evening Dan!
I'm a moderator of Russian CG Forum Arttower.ru. Could you give us the permisson to publish the Russian translation of this article (http://www.libraw.su/articles/raw-module.html) on our site?
LibRaw need to seek to arbitrary position in input stream. So, there is no way to read from stdin.
You may implement you own LibRaw_datastreeam class with full buffering.
http://www.digitalcolour.org/toolbox.htm
Dr Green has matlab code for CIECAM02.
As for profiles. There is not a profile as such. You need to determine your own cameras RGB to XYZ response. If you have a D70s I could send you some matrixes that I made earlier. I am in the process of publishing a paper on the subject. Ill keep you posted.
Looks very promising.
Is there some code (plus profile) to play with?
Hi
I successfully applied CIECAM02 to a RAW imaging workflow. The main problem was to identify the adopted white from scene colorimerty as an input to CIECAM02. I ended up using the cameras white balance for ease in order to complete the experiment. The scene illumination was calculated from ISO and Exposure and gave favorable results. The main part of the process was to characterise the camera using a double monochromator and calculate the cameras spectral response. This was then used to determine the device RGB to XYZ matrix by reducing errors in JMH space for different values of La and white point.
The resulting matrices were used to transform RAW RGB to XYZ according to scene white and La and then passed through CIECAM02.
The internal coordinates used were JMH and output to standard sRGB viewing conditions through the reverse CIECAM02.
I got some pretty good results, (although maybe not appearance perfect) compared to the sRGB JPEG produced by the Nikon D70s.
DCRAW and Matlab used for computation.
The problem is in MacOS X fseek() call. It takes 32-bit offset (long int). There is fseeko() function which takes off_t offset and so will work with files larger than 2Gb.
The quick fix:
in libraw/libraw_datastream.h change:
return substream?substream->seek(o,whence):fseek(f,o,whence);
to
return substream?substream->seek(o,whence):fseeko(f,o,whence);
This will break compatibility with Windows (no fseeko) and, possible, Linux. I'll prepare more universal solution (with #ifdef) today or tomorrow (to appear in 0.8-Beta5)
There is two news, good one and not-so-good :)
1. Frame offset is stored as 64 bit in this format, so there is no *theoretical* problems.
2. There is two possible sources of problems under Mac OS X:
a) one possible source is 32-bit off_t type (i.e. some special compilation flags are needed because 64-bit offsets are possible)
b) FILE * interface under Mac OS X does not support large files.
I've MacBook with MacOS 10.5 on hands, so will continue investigations. Hope, I'll find problem source today.
Pages