Camera2 在 Android API 29 中用两个物理流替换一个逻辑流 [英] Camera2 replacing one logical stream with two physical streams in Android API 29

查看:33
本文介绍了Camera2 在 Android API 29 中用两个物理流替换一个逻辑流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当Android 9(API 28)发布时,我很高兴地发现多摄像头手机的物理摄像头会暴露,我一直很沮丧无法访问它们.今天我偶然发现了 android Q

我们是否仍然能够使用 SessionConfiguration 在未暴露的物理相机上?

有人可以解释一下吗?

解决方案

这不是回溯.实际上,这种概括是让您更好地控制复杂相机设置的重要步骤.

在 API 29 之前,如果制造商无法为构成复合相机的每个镜头提供单独的cameraDevice,他们就无法向开发人员公开镜头参数.他们唯一的选择是将复合相机整体曝光.

问题不是

<块引用>

我们是否仍然能够在未公开的物理相机上使用 SessionConfiguration 创建捕获会话?

而是,

<块引用>

现在我们可以读取以前无法曝光的物理相机的特性了‼

通过新的更改,制造商可以为您提供有关后置摄像头 1"、后置摄像头 2"等的所有可用信息,即使无法对它们启动单独的捕获会话.

getPhysicalCameraIds() 参考解释:

<块引用>

在 API 级别 29 之前,所有返回的 ID 都保证由 CameraManager.getCameraIdList(),可以直接通过CameraManager.openCamera().从 API 级别 29 开始,对于每个返回的 ID,如果它也由 CameraManager.getCameraIdList()CameraManager.openCamera().否则,摄像机 ID 只能用作当前逻辑摄像机的一部分.

这意味着您可以使用 getPhysicalCameraIds()CameraManager.getCameraCharacteristics(id):

<块引用>

从 API 级别 29 开始,此函数还可用于查询只能作为逻辑多相机的一部分使用的物理相机的能力.这些相机不能not直接通过openCamera(String, CameraDevice.StateCallback, Handler).

When Android 9(API 28) was released, I was very happy to discover that the physical cameras of the phones with multiple cameras would be exposed, I had been very frustrated to not be able to access them. Today I stumbled upon the android Q documentation which says:

Starting from API level 29, some or all physical cameras may not be independently exposed to the application, in which case the physical camera IDs will not be available in CameraManager.getCameraIdList(). But the application can still query the physical cameras' characteristics by calling CameraManager.getCameraCharacteristics(String).

This statement confuses me, does it mean that Android is backtracking? what's the purpose of the change?

I'm interested in managing cameras at a very fine level, will this change prevent me from doing what I'm able to do today with Android 9?

It says that the IDs may not be listed any more but that the characteristics can still be queried, how are we supposed to get the characteristics of cameras without having their IDs? I guess we are supposed to get the physical cameras' IDs via getPhysicalCameraIds() on logical cameras, but does it means that if we wanted to use a "hidden" camera, we'd have to test a bunch of random ID strings?

And will we still be able to create capture sessions with SessionConfiguration on physical cameras that are not exposed?

Can someone shed some light on this?

解决方案

This is not backtracking. Actually, this generalization is an important step to provide you with better control of complex camera setups.

Before API 29, if the manufacturer could not provide separate cameraDevice for each of the lenses that constitute a composite camera, they had no way to expose the lens parameters to the developer. Their only choice was to expose the composite camera as whole.

The question is not

And will we still be able to create capture sessions with SessionConfiguration on physical cameras that are not exposed?

but rather,

And now we can read the characteristics of physical cameras that could not be exposed before‼

With the new change, the manufacturer can give you all available info on "Back camera1", "Back camera2", etc. even if there is no way to start separate capture sessions on them.

getPhysicalCameraIds() reference explains:

Prior to API level 29, all returned IDs are guaranteed to be returned by CameraManager.getCameraIdList(), and can be opened directly by CameraManager.openCamera(). Starting from API level 29, for each of the returned ID, if it's also returned by CameraManager.getCameraIdList(), it can be used as a standalone camera by CameraManager.openCamera(). Otherwise, the camera ID can only be used as part of the current logical camera.

This means that you can use any id returned by getPhysicalCameraIds() in CameraManager.getCameraCharacteristics(id):

From API level 29, this function can also be used to query the capabilities of physical cameras that can only be used as part of logical multi-camera. These cameras cannot not be opened directly via openCamera(String, CameraDevice.StateCallback, Handler).

这篇关于Camera2 在 Android API 29 中用两个物理流替换一个逻辑流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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