有没有办法以编程方式将 iOS 设备的相机焦点设置为无限远?
我正在创建一个应用程序,可以锁定相机焦点以进行视频录制。我想将焦点锁定到无限远,而无需用户手动调整焦点。这可能吗?谢谢!
I am creating an app that locks the camera focus for video recording purposes. I want to lock the focus to infinity without having the user manually adjust the focus. Is this possible? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
遗憾的是,没有。正如 Artem 所说,你可以将相机设置为焦点锁定模式;进入自动对焦模式(对焦,然后锁定)或连续自动对焦模式,但您无法为相机提供特定的对焦距离。
我能想到的最好的方法(对于曝光和白平衡控制,它们同样受到限制)是让用户将相机指向适当的场景(在您的情况下,是远处的场景)并让他/她按下锁定按钮。
有关捕获设备 API 的详细信息,例如:
https://developer.apple.com/library/mac/#文档/AVFoundation/Reference/AVCaptureDevice_Class/Reference/Reference.html
Sadly, no. You can set the camera into focus-locked mode, as Artem said; put into autofocus mode (focus, then lock), or continuous autofocus mode, but you can't give the camera a specific distance to focus at.
The best I've been able to come up with (for exposure and white balance control, which are similarly limited) is to have the user point the camera at an appropriate scene (in your case, something far away) and have him/her push a lock button.
Details on the capture device API, such as it is:
https://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVCaptureDevice_Class/Reference/Reference.html
这就是禁用焦点的方法,它会一直锁定焦点:
“将焦点锁定到无穷远”是什么意思?
That is the way to disable focus, it locks it for all the time:
What do you mean "lock the focus to infinity"?
AVCaptureDevice 有函数 setFocusModeLockedWithLensPosition:completionHandler:
您可以使用它设置 1.0 以实现“无限”距离
更新:
根据Apple文档,1.0并不代表焦点在无限远。
AVCaptureDevice has function setFocusModeLockedWithLensPosition:completionHandler:
You can use it to set 1.0 in order to achieve "infinity" distance
Update:
According to Apple documentation 1.0 does not represent focus at infinity.