I tried to play with the settings in Rawprocessor->imgdata.params, but couldn't figure it out.
My code looks now something like this (not production code):
int LoadRaw(char *charBuffer, int size)
{
RawProcessor->open_file(charBuffer);
// Result if enabled : http://neuland.wtf/img/camera_wb.jpeg
RawProcessor->imgdata.params.use_camera_wb = 0;
// Result if enabled: http://neuland.wtf/img/auto_wb.jpeg
RawProcessor->imgdata.params.use_auto_wb = 1;
RawProcessor->unpack();
RawProcessor->dcraw_process();
}
Followup:
in your code sample you make a copy of RawProcessor.imgdata by this line:
libraw_data_t imgD = RawProcessor.imgdata;
Than change your copy, not RawProcessor.imgdata.params
Is this a typo in code sample (you really use reference in your real code)?
Both DNG and NEF are TIFF/EP containers, so the spec you're after is the TIFF/EP spec. On top of that there is custom tags in both formats: the DNG ones are described in its spec (surprised you couldn't find it), the NEF ones you can glimpse maybe from e.g. ExifTool, but I don't think it's published by Nikon. I think you pretty much have to come up with your own writer, or use some TIFF library and extend it.
I thought that at least there should be some specs about the DNG file format. The SDK is great!
This might help me a bit.
But the thing I really need is NEF editing. If anyone has any hints please tell :-)
I found rawpy which uses libraw and reads NEF files. Loads the undemosaiced raw data.
Only thing missing now is a way to overwrite the file.
Looks like issue is earlier in the process.
One of the load_stream/unpack/dcraw_process is silently failing to allocate some memory, so when it comes to the dcraw_make_mem_image it is being told that width/height/etc are all 0, hence no error, but no return data.
If I can determine where it is failing I'll pass it on, otherwise - feel free to ignore me for now :)
Follow-up:
After looking at how the code fails in my app, it appears that:
this method is returning an object, but the `data_size` property is 0 (zero).
I guess it is possible that the call to dcraw_process also failed.
I'm going to go back to the debugger and ensure valid data is being presented - I will update when I have confirmed one way or the other.
If, on top of this, you also need accurate color reproduction, an alternative approach would be to construct a DNG from your raw bytestream, e.g. in 2 steps:
1) see e.g. rawtopgm from netpbm tools, or use ImageMagick/GraphicsMagick raw 'GRAY' format to convert to a widely known and simple PGM
2) use http://a1ex.magiclantern.fm/bleeding-edge/pgm2dng.c (adjust metadata accordingly in the source or using e.g. exiftool afterwards); see also https://github.com/fastvideo/pgm2dng
However, you'd need some (not so trivial) sensor characterization work to be able to fill the DNG metadata (basically build your own DCP). LibRaw would need this information anyway even if you went with the open_bayer() route and want more accurate color reproduction. The upside of the DNG route is that you can use many more processors/libraries in the future.
I don’t see what you are doing and therefore it’s hard to help you.
You need to set-up visual studio build environment corresponding to your build architecture. It could be done via several ways:
- vcvars32/vcvars64 on older Microsoft Visual Studio
- vcvarsall.bat x64 or x86 on newer Visual Studio
- visual studio shell
.bat files mentioned are *not* part of LibRaw but provided with Visual Studio.
I do not know what Visial Studio you use ('latest' is NOT version specification), I do not have Community Edition installed (so I do not know how it differ from other versions), etc, etc,etc.
I loaded the .pro file into qt, told it I wanted a 64 bit build, and got errors. I have a screencap of them, but there appears to be no way to attach an explanatory image to a comment here?
libraw/libraw.h: No such file or directory - dcraw_emu.cpp, dcraw_half.c,prostprocessing_benchmark.cpp
jpeglib.h: No such file or directory - defines.h
...
There are more errors, but they are similar. Basically, it isn't finding the includes where they are supposed to be.
I have the latest MSVC, community edition, installed under Windows 10. I am attempting to build libraw inside a vanilla Windows 10 powershell.
Your directions:
Unpack the distribution package (if you have got no tar+gzip, take the LibRaw distribution package in the .ZIP format) and go to folder LibRaw-X.YYY.
Set the environment parameters so that the compiler/linker would find the libraries and include-files. For Visual C++, this is done by running vcvars32.bat.
Run
nmake -f Makefile.msvc
There is no "vcvars32.bat" file in the distribution in the base folder, or in the buildfiles folder. Should I be looking somewhere else?
"Makefile.msvc" is present. However, "nmake -f Makefile.msvc" returns an error:
The term "nmake" is not recognized as the name of a cmdlet, function, script file, or operable program
You said:
You need either recompile LibRaw from source with your compiler or use precompiled dll (+MSVC runtime)
A dll imposes issues I wish to avoid. I want the code securely inside the app with no install issues. Hence my desire to build a compile-time linkable library.
Haha oh man, thanks for the answer!
I'm stupid, I just wanted it to be done and didn't look right at my garbage.
I fixed the code and the Whitebalance probleme disapeared.
But unfortunaly I ran into another problem.
The red colors seems to be shifted, so brown colors appears bluish.
Also blue seems to become orange.
Here is the correct image as jpg Converted from Photoshop
http://neuland.wtf/img/correct.jpg
and the source Raw file:
http://neuland.wtf/img/srcraw.CR3
I tried to play with the settings in Rawprocessor->imgdata.params, but couldn't figure it out.
My code looks now something like this (not production code):
Followup:
in your code sample you make a copy of RawProcessor.imgdata by this line:
libraw_data_t imgD = RawProcessor.imgdata;
Than change your copy, not RawProcessor.imgdata.params
Is this a typo in code sample (you really use reference in your real code)?
It is hard to discuss such kind of problem without having raw file sample on hands.
DNG specs are available at Adobe site: https://wwwimages2.adobe.com/content/dam/acom/en/products/photoshop/pdfs...
AFAIK, there is no public specs for NEFs
LibRaw is not able to write raw files.
Both DNG and NEF are TIFF/EP containers, so the spec you're after is the TIFF/EP spec. On top of that there is custom tags in both formats: the DNG ones are described in its spec (surprised you couldn't find it), the NEF ones you can glimpse maybe from e.g. ExifTool, but I don't think it's published by Nikon. I think you pretty much have to come up with your own writer, or use some TIFF library and extend it.
Thank you for your reply!
I thought that at least there should be some specs about the DNG file format. The SDK is great!
This might help me a bit.
But the thing I really need is NEF editing. If anyone has any hints please tell :-)
I found rawpy which uses libraw and reads NEF files. Loads the undemosaiced raw data.
Only thing missing now is a way to overwrite the file.
Looks like issue is earlier in the process.
One of the load_stream/unpack/dcraw_process is silently failing to allocate some memory, so when it comes to the dcraw_make_mem_image it is being told that width/height/etc are all 0, hence no error, but no return data.
If I can determine where it is failing I'll pass it on, otherwise - feel free to ignore me for now :)
Follow-up:
After looking at how the code fails in my app, it appears that:
this method is returning an object, but the `data_size` property is 0 (zero).
I guess it is possible that the call to dcraw_process also failed.
I'm going to go back to the debugger and ensure valid data is being presented - I will update when I have confirmed one way or the other.
LibRaw reads RAW files, but not writes into them.
To create DNG file you may use Adobe DNG SDK
If, on top of this, you also need accurate color reproduction, an alternative approach would be to construct a DNG from your raw bytestream, e.g. in 2 steps:
1) see e.g. rawtopgm from netpbm tools, or use ImageMagick/GraphicsMagick raw 'GRAY' format to convert to a widely known and simple PGM
2) use http://a1ex.magiclantern.fm/bleeding-edge/pgm2dng.c (adjust metadata accordingly in the source or using e.g. exiftool afterwards); see also https://github.com/fastvideo/pgm2dng
However, you'd need some (not so trivial) sensor characterization work to be able to fill the DNG metadata (basically build your own DCP). LibRaw would need this information anyway even if you went with the open_bayer() route and want more accurate color reproduction. The upside of the DNG route is that you can use many more processors/libraries in the future.
Thanks will have a look!
if your image is 'raw dump' (so just bytes from sensor), LibRaw::open_bayer is for you.
It is not well documented, use samples/openbayer_sample.cpp and Changelog.txt as a reference
Thank you for the info.
Panasonic 14-bit decoder is already included in LibRaw latest 'public snapshot'
I don’t see what you are doing and therefore it’s hard to help you.
You need to set-up visual studio build environment corresponding to your build architecture. It could be done via several ways:
- vcvars32/vcvars64 on older Microsoft Visual Studio
- vcvarsall.bat x64 or x86 on newer Visual Studio
- visual studio shell
.bat files mentioned are *not* part of LibRaw but provided with Visual Studio.
I do not know what Visial Studio you use ('latest' is NOT version specification), I do not have Community Edition installed (so I do not know how it differ from other versions), etc, etc,etc.
nmake -f returns the following:
run nmake from visual studio shell (it will set all paths/etc)
I loaded the .pro file into qt, told it I wanted a 64 bit build, and got errors. I have a screencap of them, but there appears to be no way to attach an explanatory image to a comment here?
There are more errors, but they are similar. Basically, it isn't finding the includes where they are supposed to be.
I have the latest MSVC, community edition, installed under Windows 10. I am attempting to build libraw inside a vanilla Windows 10 powershell.
Your directions:
nmake -f Makefile.msvc
There is no "vcvars32.bat" file in the distribution in the base folder, or in the buildfiles folder. Should I be looking somewhere else?
"Makefile.msvc" is present. However, "nmake -f Makefile.msvc" returns an error:
You said:
A dll imposes issues I wish to avoid. I want the code securely inside the app with no install issues. Hence my desire to build a compile-time linkable library.
We provide both Makefile.msvc and qmake .pro files, so rebuilding should be easy.
I was really trying hard to avoid having to build libraw, but I will give it a shot. Thank you.
Libraries built with different compilers are *not* compatible under windows (esp. if C++ library is used).
You need either recompile LibRaw from source with your compiler or use precompiled dll (+MSVC runtime)
Most likely in 2020
X-Pro3 support will not be included in 0.19.x branch
When will the 0.19.6 with it available?
Pages