AVFoundation's ultra-wide-angle camera behaves differently than the default apple camera

Thanks for reading.

I am creating a custom camera using AVFoundation.

When I maximize the wide angle with the ultra wide angle camera (when videoZoomFactor is minimized), the wide angle field of view is narrower compared to the apple default camera.

Looking at the metadata from the album, the focal length is 13mm for the apple default camera, while it is 16mm for the one I created. Below is an excerpt of the code.

Camera Settings

if let captureDevice = AVCaptureDevice.default(
      .builtInTripleCamera,
      for: .video,
      position: .back
    ) {
      self.captureDevice = captureDevice
    } else if let captureDevice = AVCaptureDevice.default(
      .builtInDualWideCamera,
      for: .video,
      position: .back
    ) {
      self.captureDevice = captureDevice
    } else if let captureDevice = AVCaptureDevice.default(
      .builtInWideAngleCamera,
      for: .video,
      position: .back
    ) {
      self.captureDevice = captureDevice
}
do {
      let input = try AVCaptureDeviceInput(device: captureDevice)
      let videoDataOutput = AVCaptureVideoDataOutput()
      // Omitted

      photoOutput = AVCapturePhotoOutput()
      guard let photoOutput = photoOutput else { return }
      photoOutput.isHighResolutionCaptureEnabled = true

      session.sessionPreset = .photo

     // Omitted
    } catch {
      
}
for connection in session.connections {
      connection.preferredVideoStabilizationMode = .cinematicExtended
}

zoom function

   func zoom(zoomFactor: CGFloat, ramping: Bool = false) {
    do {
      try captureDevice?.lockForConfiguration()
      self.zoomFactor = zoomFactor
      if ramping {
        captureDevice?.ramp(toVideoZoomFactor: zoomFactor, withRate: 10.0)
      } else {
        captureDevice?.videoZoomFactor = zoomFactor
      }
      captureDevice?.unlockForConfiguration()
    } catch {
      errorReportingService.reportError(error: error)
    }
  }

Test devices: iPhone 11, 12mini

Thanks for reading this far. I want to make it as wide angle as the apple default camera!

This app allows for a wider angle than the one I created. So I believe there is a way.

Looking at the metadata from the album, the focal length is 13mm for the apple default camera, while it is 16mm for the one I created.

Do you actually see a difference in the captured image, or is the difference only in the metadata?

Thank you for your reply! There is also a difference in the captured image.

try

connection.preferredVideoStabilizationMode = .standard

AVFoundation's ultra-wide-angle camera behaves differently than the default apple camera
 
 
Q