YUV420
包括NV12,和NV21。
記憶體分布
以4x4像素為例
記憶體大小:4x4x3/2=24個像素
NV21記憶體分布:
YYYY
YYYY
YYYY
VUVU
VUVU
代碼,基于opencv-android的java sdk
// ByteBuffer bf = ByteBuffer.wrap(bs);
// Mat mat_src = new Mat(height * 3 / 2, width, CvType.CV_8UC1, bf);
Mat mat_src = new Mat(height * 3 / 2, width, CvType.CV_8UC1);
mat_src.put(0, 0, bs);
Mat mat_dst = new Mat(height, width, CvType.CV_8UC3); //
Imgproc.cvtColor(mat_src, mat_dst, Imgproc.COLOR_YUV2RGB_NV12);
Imgcodecs.imwrite("/sdcard/save.jpg", mat_dst);