Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to focus FRONT camera on device using iOS, swift?

Tags:

ios

swift

camera

it seems that front camera doesn't support focusMode.

func configureDevice() {
    if let device = captureDevice {
        let focusMode: AVCaptureFocusMode = .AutoFocus
        if device.isFocusModeSupported(focusMode) {
            device.lockForConfiguration(nil)
            device.focusMode = AVCaptureFocusMode.AutoFocus
            device.unlockForConfiguration()
            println("configured device")
        }
    }
}

This code doesn't run because

if device.isFocusModeSupported(focusMode) 

returns false.

But within the built-in-camera-app, front camera can focus on tap.

Is there any way implement tap-to-focus on the FRONT camera?

like image 677
Joon. P Avatar asked Jan 08 '23 19:01

Joon. P


1 Answers

The front-facing camera does not support tap-to-focus on any iPhone. You can use device.focusPointOfInterestSupported property to check if you can do tap-to-focus (but you will get false, as with isFocusModeSupported())

What you are seeing is tap-for-exposure, and you can check for that with device.exposurePointOfInterestSupported. Once you know that you can use it, use device.exposurePointOfInterest to set your PoI.

All the details of each mode is explained to detail in Apple Docs

Hope it helps!

like image 52
Jiri Trecak Avatar answered Jan 17 '23 23:01

Jiri Trecak