I solved the problem by creating another new project in VS2010 and copy everything to the new project. I don't know why this can solve the problem though. Btw, examples work well. :)
It may be caused by read-only memory in .Net Bitmap object (I know nothing about Bitmap type).
After you've called dcraw_make_mem_image, the RGB pixels are contained in image->data. You may try to create Bitmap directly from this array without extra copy_mem_image() call.
Thanks for your quick reply, but even though I changed the 'step' to image->width*3, it still gives me an error at the line of copy_mem_image(&bmpPtr, step, 0). The error is: Unhandled exception at 0x77ea15de in Raw_Tool.exe: 0xC0000005: Access violation. Could you tell me why?
Should the 'step', which is also called stride for bitmap, has to be a multiple of 4?? If width*3 is not multiple of 4, would it gives an error when creating an bitmap object??
Your 'step' calculation is wrong. copy_mem_image accept step in bytes, for 8-bit images it is width*3.
You calculate step as width*(24/8)*3 so width*9.
Sorry, no 0.14.4 on hand (this is more-than-one-year version).
I've made a quick check: downloaded LibRaw 0.14.7 Win32 binary from http://www.libraw.org/download#stable
and use dcraw_emu.exe for decoding Samsung NX-100 SRW file.
No additional files appear, only expected .tiff or .ppm one.
Coolscan 4000 is not in the list of supported cameras :)
Generally, files from Scanners should be 3-component, not bayer-pattern. So, camera-targeted NEF-handling code will not work with scanner files because only one per-pixel component is expected.
BTW, if you provide any sample of Coolscan .NEF output, it will be analyzed in depth. May be, it is easy to add support for these files to LibRaw
Could you please provide more details about your working environment:
- what application do you use for decode files?
- what LibRaw version do you use?
I finally can display the image using LibRaw together with OpenCV. However, I found that it is okay to display .CR2 files of 5D Mark III but .CR2 files of 5D Mark II. It gives a error:
"An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll
Additional information: Parameter is not valid."
Is there any difference between the .CR2 files of 5D Mark II and Mark III?
My code is:
int check = Processor1->dcraw_process();
//process the image into memory buffer
libraw_processed_image_t *image = Processor1->dcraw_make_mem_image(&check);
//create a Mat object by data obtained from LibRaw
cv::Mat cvImage(cv::Size(image->width, image->height), CV_8UC3, image->data, cv::Mat::AUTO_STEP);
cv::cvtColor(cvImage, cvImage, CV_RGB2BGR); //Convert RGB to BGR
IntPtr ptr(cvImage.ptr()); //create a pointer based on the Mat object image
//Error occurs in the following statement, the last line with 'ptr'
Bitmap^ b = gcnew Bitmap(cvImage.cols,
cvImage.rows,
cvImage.step,
PixelFormat::Format24bppRgb,
ptr); //bitmap object of the image
I'm trying to open phase one images which have PPM thumbnails. When I extract the thumbnail with dcraw I get PPM. When I use libraw I seem to get just the RGB data, without the PPM header. Am I doing something wrong or is it getting stripped?
LibRaw does not contain any drawing code. You need to implement it yourself.
Histograms are calculated for auto-brightness code, but these histograms are not intended to use in external application:
- histograms calculated before white balance and brightness applied
- the actual pixel value is divided by 8 to make histograms compact.
I solved the problem by creating another new project in VS2010 and copy everything to the new project. I don't know why this can solve the problem though. Btw, examples work well. :)
Are the LibRaw examples works OK?
You also need to turn off auto brightness. If not, values will be scaled to fill full data range.
It may be caused by read-only memory in .Net Bitmap object (I know nothing about Bitmap type).
After you've called dcraw_make_mem_image, the RGB pixels are contained in image->data. You may try to create Bitmap directly from this array without extra copy_mem_image() call.
Thanks for your quick reply, but even though I changed the 'step' to image->width*3, it still gives me an error at the line of copy_mem_image(&bmpPtr, step, 0). The error is: Unhandled exception at 0x77ea15de in Raw_Tool.exe: 0xC0000005: Access violation. Could you tell me why?
Should the 'step', which is also called stride for bitmap, has to be a multiple of 4?? If width*3 is not multiple of 4, would it gives an error when creating an bitmap object??
copy_mem_image() copies image data without alpha channel (4th byte).
If you need alpha channel in your bitmap, you need to use per-pixel copy in a loop.
Your 'step' calculation is wrong. copy_mem_image accept step in bytes, for 8-bit images it is width*3.
You calculate step as width*(24/8)*3 so width*9.
Could you please provide more info (stack trace of crash, or test program to reproduce or so)?
Thanks again for your time. I found the camera list ;-)
Thanks for file. Downloaded it, you may remove the file from Dropbox.
The list of supported cameras is updated very frequently, so no list on website. There is API call LibRaw::cameraList().
Thank for your answer!
Is there a page where i can see all supported cameras? Maybe i just didn't find it so far...
If you like have a look at it you should find an example .nef file (coolscan4000.zip) within the next minutes at my Dropbox:
https://www.dropbox.com/sh/oxj1kd92vb62igf/EAFfqdqQ0c/Bilder
Thanks again!
Sorry, no 0.14.4 on hand (this is more-than-one-year version).
I've made a quick check: downloaded LibRaw 0.14.7 Win32 binary from http://www.libraw.org/download#stable
and use dcraw_emu.exe for decoding Samsung NX-100 SRW file.
No additional files appear, only expected .tiff or .ppm one.
In this case, I'm using Shotwell 0.13.1+trunk, and we're using LibRaw version 0.14.4.
Coolscan 4000 is not in the list of supported cameras :)
Generally, files from Scanners should be 3-component, not bayer-pattern. So, camera-targeted NEF-handling code will not work with scanner files because only one per-pixel component is expected.
BTW, if you provide any sample of Coolscan .NEF output, it will be analyzed in depth. May be, it is easy to add support for these files to LibRaw
Could you please provide more details about your working environment:
- what application do you use for decode files?
- what LibRaw version do you use?
I'm not OpenCV specialist, so I cannot help with OpenCV/System.drawing errors.
I finally can display the image using LibRaw together with OpenCV. However, I found that it is okay to display .CR2 files of 5D Mark III but .CR2 files of 5D Mark II. It gives a error:
"An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll
Additional information: Parameter is not valid."
Is there any difference between the .CR2 files of 5D Mark II and Mark III?
My code is:
int check = Processor1->dcraw_process();
//process the image into memory buffer
libraw_processed_image_t *image = Processor1->dcraw_make_mem_image(&check);
//create a Mat object by data obtained from LibRaw
cv::Mat cvImage(cv::Size(image->width, image->height), CV_8UC3, image->data, cv::Mat::AUTO_STEP);
cv::cvtColor(cvImage, cvImage, CV_RGB2BGR); //Convert RGB to BGR
IntPtr ptr(cvImage.ptr()); //create a pointer based on the Mat object image
//Error occurs in the following statement, the last line with 'ptr'
Bitmap^ b = gcnew Bitmap(cvImage.cols,
cvImage.rows,
cvImage.step,
PixelFormat::Format24bppRgb,
ptr); //bitmap object of the image
You may use
LibRaw* processor1;
and than use
processor1= new LibRaw;
in the constructor of your object
dcraw produces *file*, not in-memory object.
Dcraw file output is emulated in dcraw_emu sample
OK, I see, so that aspect of dcraw output is not emulated and that's intentional?
The PPM header is added by dcraw on file write.
I'm trying to open phase one images which have PPM thumbnails. When I extract the thumbnail with dcraw I get PPM. When I use libraw I seem to get just the RGB data, without the PPM header. Am I doing something wrong or is it getting stripped?
LibRaw does not contain any drawing code. You need to implement it yourself.
Histograms are calculated for auto-brightness code, but these histograms are not intended to use in external application:
- histograms calculated before white balance and brightness applied
- the actual pixel value is divided by 8 to make histograms compact.
Yes, you may simple pack linear 16-bit data (bayer pattern or after demosaic) into DNG
Pages