我正在使用 Android camera2 API。
我可以在手动对焦模式下使用 LENS_FOCUS_DISTANCE 获得焦距值。但是,AF 模式下该属性始终为零。有什么办法可以在AF模式下获得焦距?
我正在使用 Android camera2 API。
我可以在手动对焦模式下使用 LENS_FOCUS_DISTANCE 获得焦距值。但是,AF 模式下该属性始终为零。有什么办法可以在AF模式下获得焦距?
Shortest distance from frontmost surface of the lens that can be brought into sharp focus.
If the lens is fixed-focus, this will be 0.
http://developer.android.com/intl/es/reference/android/hardware/camera2/CameraCharacteristics.html
In other way, if you want to manage focus, remember that LENS_INFO_MINIMUM_FOCUS_DISTANCE
give you the minimum focus, but to get the "Max" focus you must use LENS_INFO_HYPERFOCAL_DISTANCE
.
float yourMinFocus = mCameraCharacteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE);
float yourMaxFocus = mCameraCharacteristics.get(CameraCharacteristics.LENS_INFO_HYPERFOCAL_DISTANCE);
For 2021 when using CameraX, here's how to find camera characteristics such as 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);
如果值为LENS_INFO_MINIMUM_FOCUS_DISTANCE
0,则表示为定焦,不支持手动对焦。功能有限 - 存在于所有报告至少HARDWARE_LEVEL_LIMITED