Hi I'm trying to use Android's PreviewCallback to perform some processing with opencv on the frames captured OnPreviewFrame. The problem I'm having is while testing that everything works before the processing, when setting the byte[] to a Mat and then the Mat to a bitmap, the bitmap looks like color noise.
mCamera.setPreviewCallback(new Camera.PreviewCallback() {
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
Mat color = new Mat(480,640, CvType.CV_8UC1);
color.put(0, 0, data);
Mat imageMat = new Mat(480,640,CvType.CV_8UC1);
Bitmap bmpOut = Bitmap.createBitmap(color.width(),color.height(),
Bitmap.Config.ARGB_8888);
Imgproc.cvtColor(color,imageMat, Imgproc.COLOR_YUV420sp2RGBA);
Utils.matToBitmap(imageMat,bmpOut,true);
image.setImageBitmap(bmpOut);
}
Any help would be greatly appreciated!