在屏幕竖屏的时候,我是这样处理Mat的。
“`
private Mat matLin;//临时图像对象
mGray = inputFrame.gray();
Core.transpose(mGray, matLin);
if (camera_scene == CAMERA_FRONT) {//前置摄像头
Core.flip(matLin, mGray, 1);
//转置函数,将图像顺时针顺转(对换)
Core.flip(mGray, matLin, 0);
mGray = matLin;
} else if (camera_scene == CAMERA_BACK) {//后置摄像头
//转置函数,将图像翻转(顺时针90度)
Core.transpose(mGray, matLin);
Core.flip(matLin, mGray, 1);
}
然后在横屏的时候我还是用到了上面的代码。结果在打开Activity的时候,SurfaceView一片漆黑。看了一下log,如下:
E/CameraBridge: Utils.matToBitmap() throws an exception: /build/master_pack-android/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_U