func coordinateRotation()

in depth-anything-example/DepthApp/ViewfinderView.swift [51:71]


        func coordinateRotation() {
            guard let input = session?.inputs.first as? AVCaptureDeviceInput else {
                rotationCoordinator = nil
                rotationObservation = nil
                return
            }

            rotationCoordinator = AVCaptureDevice.RotationCoordinator(
                device: input.device,
                previewLayer: layer
            )
            previewLayer.connection?.videoRotationAngle = rotationCoordinator!.videoRotationAngleForHorizonLevelPreview

            rotationObservation = rotationCoordinator!.observe(
                \.videoRotationAngleForHorizonLevelPreview,
                 options: .new
            ) { [unowned self] _, change in
                guard let angle = change.newValue else { return }
                self.previewLayer.connection?.videoRotationAngle = angle
            }
        }