同时访问后置和前置摄像头 [英] Access both back and front cameras simultaneously

查看:29
本文介绍了同时访问后置和前置摄像头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要实现的目标:同时访问前置和后置摄像头.

What I'm trying to achieve: access both front and back cameras at the same time.

我研究过的内容:我知道 Android 相机 API 不支持使用多个相机实例,您必须先释放一个相机,然后才能使用另一个相机.我已经阅读了数十个有关此的问题,我知道在某些设备上这是可能的(例如三星 S4 或他们的其他新设备).我还发现可以在某些设备上的 Android KitKat 中访问它们.我也知道在 api >= 21 上,使用 camera2 API,可以同时访问它们,因为它是线程安全的.

What I've researched: I know android camera API doesn't give support for using multiple instances of the Camera and you have to release a camera before using the other one. I've read tens of questions about this, I know on some devices it's possible (like Samsung S4, or other new devices from them). I've also found out that it's possible to have access to both of them in Android KitKat on SOME devices. I also know that on api >= 21, using the camera2 API, it's possible to access both of them at the same time because it's thread safe.

到目前为止,我已经完成了:一次访问一个摄像头以提供画中画的实现.

What I've got so far: implementation for accessing the cameras one at the time in order to provide a picture-in-picture.

我知道不可能在每台设备上同时实现双摄像头,我只是想要一种方法使其可用于某些设备.

I know it's not possible to implement dual simultaneously camera on every device, I just want a way to make it available to some devices.

如何测试设备是否能够同时访问它们?

How can I test to see if the device is capable of accessing both of them?

我也搜索了一个可以让我这样做的图书馆,但我没有找到任何东西.有这样的图书馆吗?

I've also searched for a library that can allow me such thing, but I didn't find anything. Is there such a library?

我想让此功能可用于尽可能多的设备,而对于其他设备,我将保留该功能的当前状态(一一).

I would like to make this feature available for as many devices as possible, and for the others, I'll leave the current state (one by one) of the feature.

谁能帮助我,至少提供一些建议?

Can anyone please help me, at least with some pieces of advice?

谢谢!

推荐答案

Android 摄像头 API 通常允许同时使用多个摄像头,但实际上大多数设备没有足够的硬件资源来支持这一点 - 例如,通常只有一个摄像头图像处理器由两个摄像头共享.

The Android camera APIs generally allow multiple cameras to be used at the same time, but most devices do not have enough hardware resources to support that in practice - for example, there's often only one camera image processor shared by both cameras.

Android API 中没有任何查询可以预先告诉您是否可以同时使用多个摄像头.

There's no query that's included in the Android APIs that'll tell you up front if you can use multiple cameras at the same time.

唯一的判断方法是在您已经打开第二个摄像头时尝试打开第二个摄像头.如果您可以打开第二个摄像头,则可以进行画中画等操作.如果您在尝试打开第二个摄像头时遇到异常,则该特定设备不支持同时打开两个摄像头.

The only way to tell is to try to open a second camera when you already have one open. If you can open the second camera, then you can do picture-in-picture, etc. If you get an exception trying to open the second camera, then that particular device doesn't support having both cameras open.

这篇关于同时访问后置和前置摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆