我正在尝试将前置摄像头预览覆盖在后置摄像头预览之上。我可以访问前置或后置摄像头,但不能同时访问它们。
这是我的代码:
活动主.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_framelayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<org.opencv.android.JavaCameraView
android:id="@+id/CameraViewBack"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
opencv:camera_id="back"
opencv:show_fps="true" />
<!-- camera_id: "any", "back", "front" or by number value -->
<org.opencv.android.JavaCameraView
android:id="@+id/CameraViewFront"
android:layout_width="200dp"
android:layout_height="200dp"
android:visibility="gone"
opencv:camera_id="front"
opencv:show_fps="true" />
</FrameLayout>
MainActivity.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_main);
mFrameLayout = (FrameLayout) findViewById(R.id.main_framelayout);
mOpenCvCameraViewBack = (CameraBridgeViewBase) findViewById(R.id.CameraViewBack);
mOpenCvCameraViewBack.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraViewBack.setCvCameraViewListener(this);
mOpenCvCameraViewFront = (CameraBridgeViewBase) findViewById(R.id.CameraViewFront);
mOpenCvCameraViewFront.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraViewFront.setCvCameraViewListener(this);
}
问题:我只能在屏幕上看到后置摄像头视图。我想要的是一个小窗口,上面覆盖着前置摄像头视图,这样我就可以看到两者。
我怎样才能做到这一点?谢谢。