本文介绍了Android的OpenCV的同时显示(前+后)摄像机应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图覆盖在相机背面preVIEW上方的前置摄像头preVIEW。我能够一起获得正面或背面的摄像头,但不是他们两个。

I'm trying to overlay the front camera preview on top of the back camera preview. I'm able to access either front or back camera, but not both of them together.

下面是我的code:

activity_main.xml中:

activity_main.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:

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);


    }

问题:我只看到在屏幕后面的摄像头视图。我要的是一个小窗口覆盖在此之上,所以我可以同时看到前置摄像头视图。

Problem: I only see the back camera view over the screen. What I want is a small window with the front camera view overlayed on top of this so I can see both.

我怎样才能做到这一点?谢谢你。

How can I do this? Thanks.

推荐答案

无法做到这一点。

CV ::为Android VideoCapture类实现不支持
  几款相机在同一时间。
  Android相机API不支持直流相机使用

这篇关于Android的OpenCV的同时显示(前+后)摄像机应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 16:51