convert camera preview byte array data to bitmap
YuvImage yuv_image = new YuvImage(imageByte, ImageFormat.NV21, width, height, null);
Rect rect = new Rect(0, 0, width, height);
ByteArrayOutputStream output_stream = new ByteArrayOutputStream();
yuv_image.compressToJpeg(rect, 100, output_stream);
byte[] byt = output_stream.toByteArray();
Bitmap full = BitmapFactory.decodeByteArray(byt, 0, byt.length);
convert camera preview byte array data to OpenCV mat format
Mat mYuv = new Mat(height, width, CvType.CV_8UC1);
mYuv.put(0, 0, data);
note that you should be aware CvType.CV_8UC1
, if you cannot get mat correctly, you should try CvType.CV_8UC3
instead.