我正在使用SurfaceView捕获图像并在public void onPreviewFrame4(byte []数据,相机相机)中获取Yuv Raw预览数据
我必须在onPreviewFrame上执行一些图像预处理,所以我需要将Yuv预览数据转换为RGB数据,而不是图像预处理并返回到Yuv数据.
我使用了两个函数来编码和解码Yuv数据到RGB,如下所示:
public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
if (data != null) {
Log.i("DEBUG", "data Not Null");
// Preprocessing
Log.i("DEBUG", "Try For Image Processing");
Camera.Parameters mParameters = camera.getParameters();
Size mSize = mParameters.getPreviewSize();
int mWidth = mSize.width;
int mHeight = mSize.height;
int[] mIntArray = new int[mWidth * mHeight];
// Decode Yuv data to integer array
decodeYUV420SP(mIntArray, data, mWidth, mHeight);
// Converting int mIntArray to Bitmap and
// than image …Run Code Online (Sandbox Code Playgroud) 我正在编写一个应用摄像头的应用程序,将其转换为rgb,以便进行一些处理.
它适用于使用NV21 Yuv格式的旧相机实现.我遇到的问题是使用新的Yuv格式YUV_420_888.在新的Camera2 Api中,图像不再正确转换为RGB,后者发送YUV_420_888 yuv格式而不是NV21(YUV_420_SP)格式.
有人可以告诉我如何将YUV_420_888转换为RGB?
谢谢