我正在使用Android camera2 API。

我可以在手动对焦模式下使用LENS_FOCUS_DISTANCE获得对焦距离值。但是,该属性在AF模式下始终为零。在自动对焦模式下,有什么方法可以获取对焦距离吗?

最佳答案


http://developer.android.com/intl/es/reference/android/hardware/camera2/CameraCharacteristics.html
换句话说,如果要管理焦点,请记住LENS_INFO_MINIMUM_FOCUS_DISTANCE为您提供了最小的焦点,但是要获得“最大”焦点,您必须使用LENS_INFO_HYPERFOCAL_DISTANCE

float yourMinFocus = mCameraCharacteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE);
float yourMaxFocus = mCameraCharacteristics.get(CameraCharacteristics.LENS_INFO_HYPERFOCAL_DISTANCE);

对于2021年使用CameraX时,以下是查找相机特征的方法,例如LENS_INFO_MINIMUM_FOCUS_DISTANCE:
theCamera = cameraProvider.bindToLifecycle(...
CameraCharacteristics camChars = Camera2CameraInfo
   .extractCameraCharacteristics(theCamera.getCameraInfo());
float discoveredMinFocusDistance = camChars
   .get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE);
Log.i("dev", "min focus is " + discoveredMinFocusDistance);

关于Android camera2 API在AF模式下获得对焦距离,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30724839/

10-10 23:31