Android camera2 API 在 AF 模式下获取焦距 [英] Android camera2 API get focus distance in AF mode

查看:88
本文介绍了Android camera2 API 在 AF 模式下获取焦距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Android camera2 API.

I'm working with Android camera2 API.

我可以在手动对焦模式下使用 LENS_FOCUS_DISTANCE 获得焦距值.但是,该属性在 AF 模式下始终为零.有没有办法在AF模式下获得焦距?

I can get focus distance value using LENS_FOCUS_DISTANCE in manual focus mode. However, the property is always zero in AF mode. Is there any way to get focus distance in AF mode?

推荐答案

距镜头最前表面的最短距离成为焦点.

Shortest distance from frontmost surface of the lens that can be brought into sharp focus.

如果镜头是定焦的,则为0.

If the lens is fixed-focus, this will be 0.

http://developer.android.com/intl/es/reference/android/hardware/camera2/CameraCharacteristics.html

换句话说,如果您想管理焦点,请记住 LENS_INFO_MINIMUM_FOCUS_DISTANCE 为您提供最小焦点,但要获得最大"焦点你必须使用LENS_INFO_HYPERFOCAL_DISTANCE.

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);


对于 2021 年使用 CameraX 时,以下是查找相机特征(例如 LENS_INFO_MINIMUM_FOCUS_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);

这篇关于Android camera2 API 在 AF 模式下获取焦距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆