我目前正在试用openCV的java示例,即android中的人脸检测。但是,相机创建的视图不是镜像,我试着将android:screenOrientation设置为reverseLandscape,但没有工作。我想尝试做到这一点,有什么建议吗?
版面代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<org.opencv.android.JavaCameraView
android:id="@+id/fd_activity_surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:screenOrientation="reverseLandscape"
/>
实例化
private CameraBridgeViewBase mOpenCvCameraView;OpenCV加载
mOpenCvCameraView.setCameraIndex(1);
mOpenCvCameraView.enableView();onCreate()方法
mOpenCvCameraView = findViewById(R.id.fd_activity_surface_view);
mOpenCvCameraView.setCvCameraViewListener(this);mOpenCvCameraView不包含setDisplayOrientation()方法,setRotation(180)返回给我一个黑色显示。
发布于 2017-11-27 10:24:20
对镜像的最小修改是将以下代码添加到CvCameraViewListener2中
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
Mat rgba = inputFrame.rgba();
Core.flip(rgba, rgba, 1);
return rgba;
}这不是最有效的方法,但可能是可以接受的。在我比较弱的测试设备上,这会将FPS从7.17减少到7.15。
发布于 2020-12-18 11:34:08
对于横向反向:
Core.flip(rgba, rgba, 1);垂直反转:
Core.flip(rgba, rgba, -1);https://stackoverflow.com/questions/47497345
复制相似问题