在 android 中,如果我有 min api 21,cameraX 是否涵盖所有设备,或者我是否需要为旧设备维护 camera1 实现?
In android if I have min api 21 does cameraX cover all devices or do I need to maintain a camera1 implementation for older devices?
我目前有一个最小 api 为 21 的应用程序,它同时具有 camera1 和 camera2 实现。根据下面的代码我select是用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 后备的所有情况?我们的很多客户都在发展中市场,因此我们需要保持对尽可能多的旧设备的支持。
cameraX 没有 Camera API1 fallback. They rely on camera2 LEGACY support, but yes, the library includes many workarounds for specific problems. Please look at the list of devices they tested: https://developer.android.com/training/camerax/devices.
你没有解释你之前使用 camera1 后备的“所有情况”是什么,但如果你有这样的列表,你可以浏览 release notes to check whether they are addressed by the current version of the library. If they are not, you are welcome to add them to the issues list。
我目前有一个最小 api 为 21 的应用程序,它同时具有 camera1 和 camera2 实现。根据下面的代码我select是用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 后备的所有情况?我们的很多客户都在发展中市场,因此我们需要保持对尽可能多的旧设备的支持。
cameraX 没有 Camera API1 fallback. They rely on camera2 LEGACY support, but yes, the library includes many workarounds for specific problems. Please look at the list of devices they tested: https://developer.android.com/training/camerax/devices.
你没有解释你之前使用 camera1 后备的“所有情况”是什么,但如果你有这样的列表,你可以浏览 release notes to check whether they are addressed by the current version of the library. If they are not, you are welcome to add them to the issues list。