0 Replies
      Latest reply on Dec 2, 2019 11:49 PM by powderscotty
      powderscotty Level 1 Level 1 (0 points)

        AVCaptureDeviceInput zooms in compared to Camera view in Photo - how to obtain complete vision of the camera to use in app?


        There are 2 similar questions on stackoverflow.com that are 5 and 10 years old, but none answer how to keep the complete view from the camera in photo view for the AVCaptureDeviceInput to use in your app.

        • AV Foundation camera preview layer gets zoomed in, how to zoom out?
        • AVCam: Zoom further out (as it is possible for photo-mode)?

        I experience the same problem as described in the posts mentioned above with AVCaptureDeviceInput... compared with the camera view in photo mode on the iPhone X the captured stream in AVCaptureDeviceInput is very much zoomed in...

        For my app, I need to have a wide-angle view to allow the user to move around a bit without having to adjust the position of the phone all the time. Is there any chance I can make use of the completely zoomed out picture that is captured by the camera in AVCaptureDeviceInput?


        Please see below my code and the alternatives I have tried out, but all result in the zoomed-in view:


        func setupAVCapture() {
          var deviceInput: AVCaptureDeviceInput!

          // Select a video device, make an input
          let videoDevice = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: .video, position: .back).devices.first
          // deviceTypes: [.builtInWideAngleCamera], oder deviceTypes: [.builtInTelephotoCamera],
          do {
          deviceInput = try AVCaptureDeviceInput(device: videoDevice!)
          } catch {
          print("Could not create video device input: \(error)")

          session.sessionPreset = AVCaptureSession.Preset.high;
          // taken from: https://stackoverflow.com/questions/32542745/avcam-zoom-further-out-as-it-is-possible-for-photo-mode
          // alternative tried out:
          // session.sessionPreset = AVCaptureSession.Preset.photo
          // taken from: https://stackoverflow.com/questions/3676607/av-foundation-camera-preview-layer-gets-zoomed-in-how-to-zoom-out?answertab=active#tab-top and disabled next line of code:
          // alternative original setting:
          // session.sessionPreset = .vga640x480
          // Model image size is smaller. alternative values: "vga640x480" oder "photo" oder hd4K3840x2160
          // voreingestellt und funktionierend: vga640x480

          // Add a video input
          guard session.canAddInput(deviceInput) else {
          print("Could not add video device input to the session")



        Any hints how to get the complete wide angle view from the camera in photo mode to use in avcapture will be highly appreciated.