I've been stuck for hours on something, I hope you can help me.
I am working on integrating a camera into an application, and I would like to exploit the RAW data that can be retrieved by assigning the value 'bayer-mipi-10grbg' to the 'picture-format' parameter. With my Redmi Note 6, in the OnPictureTaken callback, I get a byte array (15,482,880 bytes).
I have not yet managed to exploit this bytes array.
I read that it was necessary to debayer the data in order to obtain a usable RGB image. So I opted for OpenCv to make my life easier, see the following piece of code:
public void OnPictureTaken(byte[] data, Camera camera)
{
var height = 4032;
var width = 3024;
var mBayer = new Mat(width, height, CvType.Cv16u);
var mRgb = new Mat();
mBayer.Put(0, 0, /* data' */);
Imgproc.CvtColor(mBayer, mRgb, Imgproc.COLORBayerGR2BGR);
Imgcodecs.Imwrite($"{_galleryFolder}/{DateTime.Now.ToString("yyMMddhhmmss")}", mRgb);
}
My problem is that to build a Cv16u matrix I can't give it a bytes array to eat, if I understand correctly it needs a shorts array.
My question is, what transformation should I apply to my bytes array to get a valid shorts array?
Edit: The shorts array will obviously not be a simple copy of the bytes array, I imagine for example that the first x bytes correspond to the first value of the shorts array (this is an example). It is this transformation that I do not know about.
Edit2: 4032x3024 is the size I get from the parameter 'raw-size'. I clearly have difficulty making the link between this size and the size of the bytes array I receive. I have uploaded a file that contains the bytes array I receive (saved as is, without processing) : https://ufile.io/gsis9