I use a Canon EOS 1200D. This camera creates JPEG files with a resolution of 5184 x 3456. The camera creates also CR2 files.
I use LibRaw to open this file.
LibRaw processor;
processor.open_file("test1.CR2");
If i debug my program i can see:
processor.imgdata.sizes.raw_height = 3516
processor.imgdata.sizes.raw_width = 5344
processor.imgdata.sizes.height = 3465
processor.imgdata.sizes.width = 5202
processor.imgdata.sizes.top_margin = 51
processor.imgdata.sizes.left_margin = 142
processor.imgdata.sizes.iheight = 3465
processor.imgdata.sizes.iwidth = 5202
1/ Why the resolution of 5184 x 3456 does not appear?
I see also four objects in: processor.tiff_ifd like this:
[0] {t_width=5184 t_height=3456 bps=8 ...}
[1] {t_width=160 t_height=120 bps=8 ...}
[2] {t_width=668 t_height=432 bps=16 ...}
[3] {t_width=5344 t_height=3516 bps=14 ...}
2/ What does these four objects?
3/ I do not understand what the statement:
processor.unpack();
do. Does it convert from RGBG format to RGB format?
Now, i would like create an cv::Mat with the resolution of 5184 x 3456 and without losing accuracy.
4/ So how i can convert my CR2 file to a cv::Mat with format CV_16UC3?
From several CR2 files, i would like create a new image wich is the average.
5/ So, when i have a cv::Mat with format CV_16UC3, how i can save it in a file without losing accuracy?
Thank you.
EDIT
Ok, so I have to use:
processor.imgdata.params.output_bps = 16;
processor.open_file("test1.CR2");
processor.unpack();
processor.dcraw_process();
libraw_processed_image_t* output = processor.dcraw_make_mem_image();
But how i can specify to use the JPEG resolution? I think it is with:
processor.imgdata.params.cropbox
but how specify the JPEG resolution without hard coding?
Please refer to LibRAW documentation.
unpack
method only unpacks data from raw file format without any demosaic. It is still the same raw data. To get RGB data, please refer to "Postprocessing" section in the documentation, particularlydcraw_process