我如何知道相机是否对焦?

我如何知道相机是否对焦?

问题描述:

我要执行以下操作:
当相机对焦后,该应用程序将自动拍照。
但是我发现无法检测相机是否对焦。

I want to do this: When the camera is focused, the app will take picture automatically. But I found there's no way to detect if the camera is focused.

我怎么知道相机是否对焦?

How can I know if the camera is focused?

AVCuptureDevice ,您应该检查是否支持焦点。
并非所有iOS设备都支持聚焦,因此您真的需要通过调用 isFocusModeSupported:

然后开始监视 adjustingFocus 属性。这告诉您设备是否正在对焦。

Then start monitoring the adjustingFocus property. This tells you wether the device is focusing.

因此 adjustingFocus 返回不要拍照,如果它变成 NO ,则设备应对焦。

Thus while the adjustingFocus returns YES don't take the picture, if it changes into NO the device should be focused.