Hi,
Thanks for the question and sorry for the late reply.
To get the focus distance, there's an experimental feature called
Camera2Interop, which allows users to get Camera2 related information while using CameraX. LENS_FOCUS_DISTANCE can be gotten from the
capture callback similar to Camera2. The code may look like:
// Create a capture callback that gets the focus distance.
val captureCallback = object : CameraCaptureSession.CaptureCallback() {
override fun onCaptureCompleted(
session: CameraCaptureSession,
request: CaptureRequest,
result: TotalCaptureResult
) {
val lensFocusDistance = result.get(CaptureResult.LENS_FOCUS_DISTANCE)
}
}
// Use Camera2Interop to extend a use case builder with the capture callback
Camera2Interop.Extender(useCaseBuilder).setSessionCaptureCallback(captureCallback)
// Build the use case and bind it.
cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, useCaseBuilder.build())