Android 安卓可以同时使用前后摄像头吗

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12382322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:29:37  来源:igfitidea点击:

Is it possible to use front and back Camera at same time in Android

androidandroid-camera

提问by AndroDev

I want to use front and back Camera of device both at same time. In my app, first half of the screen will display preview of back camera and next half of the screen will display front camera preview.

我想同时使用设备的前后摄像头。在我的应用程序中,屏幕的前半部分将显示后置摄像头的预览,下半部分屏幕将显示前置摄像头的预览。

I have tried this with setting two different camera previews but when I open my app, first half of the screen(which displays back camera preview) does not display the preview. And second half of the screen(which displays front facing Camera) displays back facing Camera(strange).

我已经尝试过设置两个不同的相机预览,但是当我打开我的应用程序时,屏幕的前半部分(显示后置相机预览)不显示预览。屏幕的后半部分(显示前置摄像头)显示后置摄像头(奇怪)。

According to Camera.open(int) documentation:

根据Camera.open(int) 文档

Your application should only have one Camera object active at a time for a particular hardware camera.

对于特定的硬件相机,您的应用程序一次应该只有一个活动的 Camera 对象 。

This means if both camera hardware (front and back) are different and can be opened at same time.

这意味着如果两个相机硬件(正面和背面)不同并且可以同时打开。

In my application, I am using the same above api. This does not give any exception or error when I open and call Camera.startPreview();for both cameras at same time. But still it is not working. I can see only one camera preview at a time.

在我的应用程序中,我使用了与上面相同的 api。当我同时打开和调用Camera.startPreview();两个摄像头时,这不会给出任何异常或错误。但它仍然无法正常工作。我一次只能看到一个相机预览。

Is there anything which I am missing here to use both cameras at same time?

我在这里缺少什么可以同时使用两个相机吗?

回答by user3094508

I got simultaneous dual camera access working on the HTC ONE M8

我在 HTC ONE M8 上同时使用双摄像头访问

Video: http://youtu.be/lt8N1Lpa9Zw
Feel free to use my code from here: https://bitbucket.org/jens_grubert/androiddualcameracapture/

视频:http: //youtu.be/lt8N1Lpa9Zw
随意从这里使用我的代码:https: //bitbucket.org/jens_grubert/androiddualcameracapture/

回答by user3013507

No

Your application should only have one Camera object active at a time for a particular hardware camera.

对于特定的硬件相机,您的应用程序一次应该只有一个处于活动状态的 Camera 对象。

look at this http://developer.android.com/reference/android/hardware/Camera.html#open(int)

看看这个http://developer.android.com/reference/android/hardware/Camera.html#open(int)