简体   繁体   中英

How to get the lens position on ARKit 1.5

Before ARKit 1.5, we had no way to adjust the focus of the camera and getting the lens position would always return the same value. With ARKit 1.5, however, we can now use autofocus by setting ARWorldTrackingConfiguration.isAutoFocusEnabled . My question is that, is there any way to get the current lens position from ARKit so that I can apply an out-of-focus effect on my virtual objects? I had a look at some classes where this information may be stored, like ARFrame or ARSession , but they don't seem to have such a field.

I've stumbled upon this thread where the OP says that he was able to set the lens position by using some private API's, but this was before the release of ARKit 1.5 and a sure way to get your app rejected by the App Store.

Are there any legal ways to get the lens position from ARKit?

My guess is: probably not, but there are things you might try.

The intrinsics matrix vended by ARCamera is defined to express focal length in pixel units. But I'm not sure if that's a measurement you could (together with others like aperture) define a depth blur effect with. Nor whether it changes during autofocus (that part you can test, at least).

The AVCapture APIs underlying ARKit offer a lensPosition indicator, but it's a generic floating point value. Zero is minimum focus distance, one is maximum, and with no real world measurement this corresponds to you wouldn't know how much blur to apply (or what physically based camera settings in SceneKit, Unity settings to use) for each possible lens position.

Even if you could put lensPosition to use, there's no API for getting the capture device used by an ARSession. You can probably safely assume it's the back (wide) camera, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM