I'm trying to capture an image from the camera preview and convert it to a Mat object using OpenCV.
I registered the callbak method public void onPreviewFrame(byte[] data, Camera camera) so I receive all preview frames from the camera, but I can't get it to convert to OpenCV Mat object.
I'm currently using the following code to convert the preview data to a Mat object:
Mat previewFrameMat = new Mat(1, data.length, CvType.CV_8U);
previewFrameMat.put(0, 0, data);
Is this the correct way to do it ? Am I using the correct image type (CvType.CV_8U) ?