我有一个使用 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
为什么我没有后置三摄微距摄像头。
我所有拥有 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.
要获取物理相机,请使用此
参考:
https://source.android.com/devices/camera/multi-camera https://source.android.com/devices/camera/multi-camera
Camera2 在 Android API 29 中用两个物理流替换一个逻辑流 https://stackoverflow.com/questions/55923506/camera2-replacing-one-logical-stream-with-two-physical-streams-in-android-api-29
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)