Camera fixed focus distance

The focus of the camera (iPhone 7 plus) seems to be set at a fixed distance when running ARKit. This is fine for games but limiting for AR photo and video apps.


Is there a way to set the focus distance further away, or even better enabled autofocus while using ARKit? Presumably changing the camera's focus distance affects the field of view, but that appears to be updated with every frame anyway.


Thanks!

Replies

You are correct in assuming that focal changes will affect the camera's intrinsic parameters. During the auto-focus searching process any visual tracking would have to be paused, or you'd risk corrupting the internal keypoint map. I think for this reason, we won't see auto-focus in ARKit.


I do agree that it would be nice to be able to manually set an initial fixed focus prior to starting the tracking session.

Thanks for the response! Vuforia is able to run on iOS with autofocus, and while it is a different kind of tracking I don't think autofocus is never going to happen. If the focus distance is known for a frame, and the lens is fully calibrated, it should be able to take the difference into account.


Also since it looks like ARFrame returns a new projection matrix every frame, my hope is the API is already able to handle something like this, and it just hasn't been implemented yet.

ARKit lets you use real-world camera lens settings (you can also setFocusDistance; that may accomplish what you're looking for).


I'm using:


[cameraNode.camera setFocalLength:50.0];

[cameraNode.camera setFStop:2.0];

[cameraNode.camera setWantsHDR:YES];


to look like a 50mm lens with F2.0 aperture.

Upon further testing, I'm inclined to agree with you that it would be good to have support for continuous auto-focus in ARKit. Being able to set a range restriction (AVCaptureAutoFocusRangeRestriction) could help prevent the focus from wandering off.


I also found considerable discrepancies between our various test devices: When holding several iPhones side-by-side, the video image appears crisp and in focus on some of them, while it looks slightly blurry and out-of-focus on the others. I suppose that's to be expected and is caused by variations in the manufacturing process and/or environmental conditions.


I guess it's time to submit a feature request via https://developer.apple.com/bug-reporting

@robz: I think you misunderstood the question. You are talking about the virtual camera (SCNCamera). However, what we are discussing here is the device camera (AVCaptureDevice).

Feature request submitted.

Please add your report # to your comment for reference, thanks.

My own iPhone 7 Plus has been out of focus specifically for ARKit apps in most settings I've tried. This is not the case on the single camera iPhone 7 or in other apps that use the camera on the same device. I've filed a bug report and referenced this thread but I'm wondering now if this is an issue specific to (or at least more common on) the 7+.

Hi, also experiencing this on iPhone 8 plus. Images are really sharp on a 6s, however completely out of focus on iPhone 8 plus. Will file a bug report. Any resolution?

Had same issue on my 7 plus and now on my X