Converting YUV to YUV420 Android onPreview

我的未来我决定 提交于 2019-12-24 11:35:53

问题


a)I was wondering what is the difference between YUV and YUV420? b)I want to use the raw frames from Camera and convert them into YUV420 in real time. What is the fastest way to do this? I used bitmap factory to convert from yuv to jpg and I used onDraw() method to draw the bitmap. However, this takes some time to process. What is the best alternative to do the conversion if I want converting from YUV to YUV420?


回答1:


I found a very straight forward way to convert from NV12 to YV12/YUV 420. Two lines of code did the job for me:

public void surfaceCreated(SurfaceHolder holder) {

        try {
            // set view of surface in cameraview
            Camera.Parameters p = mCamera.getParameters();

            p.setPreviewFormat(ImageFormat.YV12);

            mCamera.setParameters(p);
            mCamera.setPreviewDisplay(holder);
            mCamera.startPreview();
            }

}



来源:https://stackoverflow.com/questions/28706700/converting-yuv-to-yuv420-android-onpreview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!