我目前有一个最小api为21的应用程序,它同时具有camera1和camera2实现。根据以下代码,我选择是使用camera1还是camera2:
val cameraIds = manager.cameraIdList
for (id in cameraIds) {
val info = manager.getCameraCharacteristics(id)
val facing = info.get(CameraCharacteristics.LENS_FACING)!!
val level = info.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)!!
val hasFullLevel = level == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL
val syncLatency = info.get(CameraCharacteristics.SYNC_MAX_LATENCY)!!
val hasEnoughCapability = syncLatency == CameraCharacteristics.SYNC_MAX_LATENCY_PER_FRAME_CONTROL
// All these are guaranteed by
// CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL, but checking
// for only the things we care about expands range of devices we can run on.
// We want:
// - Back-facing camera
// - Per-frame synchronization (so that exposure can be changed every frame)
if (facing == CameraCharacteristics.LENS_FACING_BACK && (hasFullLevel || hasEnoughCapability)) {
// Found suitable camera - get info, open, and set up outputs
foundCamera = true
break
}
}
我计划在不久的将来更新cameraX,我很想放弃camera1实现,拥有一个统一的cameraX实现。有人有cameraX的经验吗?它是否处理了我以前使用camera1回退的所有情况?我们的许多客户都在发展中市场,因此我们需要保持对尽可能多的旧设备的支持。
Camera X没有Camera API1回退。他们依赖camera2 LEGACY支持,但是的,该库包括许多针对特定问题的解决方案。请查看他们测试的设备列表:https://developer.android.com/training/camerax/devices.
你没有解释什么是";所有情况";您以前使用的是camera1回退,但如果您有这样的列表,您可以查看发行说明,以检查它们是否由库的当前版本寻址。如果没有,欢迎您将它们添加到问题列表中。