Search code examples
androidandroid-camera2

Android Camera 2 API Lens switching


I'm trying to achieve the same functionality for lens switching as default camera app has on Xiaomi MI8. Screenshot attached.

Hardware setup: Xiaomi MI8 [API 29] with back-facing camera with wide angle and telephoto lenses

Software setup: there is only one back-facing logical camera accessible through API and its physicalCameraIds list is empty.

In theory we could create a bunch of OutputConfiguration objects, set a physical camera id and create capture session but it's not possible due to lack of physicalCameraIds on Xiaomi MI8.

Does anyone has some ideas how to implement lens switching and retrieve physicalCameraIds on Xiaomi MI8? Or maybe someone tried to check physicalCameraIds on some other devices?

Back-facing camera characteristics for the all lens related fields (if it's useful for further research):

physicalCameraIds: []
availablePhysicalCameraRequestKeys: null
LENS_DISTORTION: null
LENS_FACING: 1
LENS_INFO_AVAILABLE_APERTURES: [1.8]
LENS_INFO_AVAILABLE_FILTER_DENSITIES: [0.0]
LENS_INFO_AVAILABLE_FOCAL_LENGTHS: [4.216]
LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION: [0, 1]
LENS_INFO_FOCUS_DISTANCE_CALIBRATION: 1
LENS_INFO_HYPERFOCAL_DISTANCE: 0.2835498
LENS_INFO_MINIMUM_FOCUS_DISTANCE: 10.0
LENS_INTRINSIC_CALIBRATION: null
LENS_POSE_REFERENCE: null
LENS_POSE_ROTATION: null
LENS_POSE_TRANSLATION: null

Lens selection on default camera app on Xiaomi MI8


Solution

  • You can access the wide-angle camera by its id on debug ROMs. Camera id and ROM can be provided by vendor's mobile department.