iOS camera autofocus / full range focus?

Hi there,
I’m building augmented reality app for an iPhone and so I need to use a camera on the device. It was pretty easy to set it up using ofVideoGrabber but my problem is that camera sets its field of focus at the launch and it is not what I want. Ideally, I would like to focus on short and long distances. If anyone knows a way to achieve this using openframeworks or objective c I would love to hear it!

Thanks

I have managed to find this, so I will just post an answer here as it might be helpful for someone in the future.

I have modified

if( [captureInput.device isFocusModeSupported:AVCaptureFocusModeLocked] ) [captureInput.device setFocusMode:AVCaptureFocusModeLocked];

to

AVCaptureFocusModeContinuousAutoFocus

This code is found under a function called lockExposureAndFocus() and startCapture() located at:
of_v0.9.8_ios_release/addons/ofxiOS/src/video/AVFoundationVideoGrabber.mm

1 Like