在 Android 中使用后置双摄像头

Use rear facing dual camera in Android

我正在尝试使用我的 xiaomi mi 5s plus 上的两个后置摄像头进行拍摄。 当我尝试使用 camera2 api 遍历相机的 ID 时,我只得到 2 个 ID,一个用于前置摄像头,一个用于后置摄像头。 我查看了 lg 开发示例 (http://mobile.developer.lge.com/develop/sdks/lg-dual-camera/),他们使用了 3 个 ID。当 运行 他们的示例时,应用程序崩溃。

用于获取 ID 的代码是:

CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
for(String id: manager.getCameraIdList())
    Log.e("test", id);

AndroidP 之前不支持双摄像头拍摄。AndroidP 现在支持多摄像头拍摄 -> https://developer.android.com/preview/features#camera

Different vendors provide dual cameras for their Android devices in hope to improve the photo quality for average user, more often than not, specifically tuned for special conditions like challenging illumination or distortions of selfie mode. Each vendor uses proprietary technologies to handle dual cameras, and they are not interested to disclose the implementation details. The only public interface they support is a virtual single camera which is more or less compliant with Google specs.