java - 检测所有摄像头android

标签 java android camera android-camera2

我有一个应用程序使用 Camera2 API 来预览相机。 我想在手机镜头之间做出选择。 在我的代码中,我使用以下代码:

CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
String[] ids = manager.getCameraIdList();

当我使用带有 2 个前置摄像头(常规和广角)和 3 个后置摄像头的 galaxy s10 时,我只能从管理器返回 4 个 ID:

0- regular rear
1- regular front
2- wide rear
3- wide front

为什么我没有 3 个后置微距摄像头。

问题出现在我的所有背面有 1 个以上摄像头的手机中

如何获得所有后置摄像头?

提前发送

最佳答案

根据文档,您只能获得逻辑摄像头。

public String[] getCameraIdList ()

Return the list of currently connected camera devices by identifier, including cameras that may be in use by other camera API clients.
Non-removable cameras use integers starting at 0 for their identifiers, while removable cameras have a unique identifier for each individual device, even if they are the same model.
This list doesn't contain physical cameras that can only be used as part of a logical multi-camera device.

Returns
String[]    The list of currently connected camera devices. This value cannot be null.

要获取物理相机,请使用此

enter image description here enter image description here enter image description here

引用资料:

https://source.android.com/devices/camera/multi-camera

Camera2 replacing one logical stream with two physical streams in Android API 29

关于java - 检测所有摄像头android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61800594/

相关文章:

java - 线程 "main"中的异常java.lang.NumberFormatException : For input string: "9000000000000000" under radix 16

java - removeAll() 方法花费很长时间

android - 如何以编程方式更改电话类型?

android - 使用变量时如何在 build.gradle 中查看依赖项更新?

android - 当振动完成他的模式时做 Action

android - 使用 MediaMuxer 混合相机预览 h264 编码的基本流

javascript - iOS13 getUserMedia 不适用于 chrome 和 edge

java - Greenrobot EventBus 无法调度事件

ubuntu - JTessBoxEditor 无法在 Ubuntu 16.04(OpenJDK 8 或 9)上启动

android - 使用 ACTION_GET_CONTENT 在 Android on 2.1 上选取图片和视频