我正在使用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)