Reputation: 61
I currently have an app with a minimum api of 21 that has both a camera1 and a camera2 implementation. Based on the following code I select whether to use camera1 or 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
}
}
I plan to, in the near future update to cameraX and I would love to drop the camera1 implementation and have one unified cameraX implementation. Does anyone have experience with cameraX and whether it handles all the cases that I was previously using the camera1 fallback for? A lot of our customers are in developing markets and therefore we need to maintain support for as many older devices as possible.
Upvotes: 1
Views: 649
Reputation: 57163
cameraX does not have a 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.
You don't explain what are "all the cases" you were previously using the camera1 fallback for, but if you have such list, you can go through the 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.
Upvotes: 1