OpenCV for Android: Convert Camera preview from YUV to RGB with Imgproc.cvtColor
问题 I get a runtime error if I try to convert camera preview YUV byte array to a RGB(A) byte array with Imgproc.cvtColor( mYUV_Mat, mRgba_Mat, Imgproc.COLOR_YUV420sp2RGBA, 4 ) in onPreviewFrame(byte[] data, Camera camera): Preview.java: mCamera.setPreviewCallback(new PreviewCallback() { public void onPreviewFrame(byte[] data, Camera camera) { // Pass YUV data to draw-on-top companion System.arraycopy(data, 0, mDrawOnTop.mYUVData, 0, data.length); mDrawOnTop.invalidate(); } }); DrawOnTop.java: