显示完全照相机的宽度从Mac摄像机的运行时的应用程序通过Mac催化剂

0

的问题

我知道我Air的摄像头有广泛的视野。 当我打开microsoft的竞争技术的应用程序和选择我的分机作为输入我看到一个很好的广泛的视频馈送这样的。

enter image description here

现在,我有一个我的运行使用Mac催化剂。 这里是建立合我的使用。

enter image description here

当我运行这个程序,我得到一个显着裁剪版本的视频馈送从该网络摄像头。

enter image description here

这里是类在哪里我设置的 AVCaptureSession

import Foundation
import AVFoundation


class BasicCamera: ObservableObject {
    
    @Published var authorizationState: AVAuthorizationStatus = .notDetermined
    
    let session = AVCaptureSession()
    
    init() {
        guard let device = AVCaptureDevice.default(for: .video) else {
            fatalError("Could not make capture device.")
        }
        
        guard let input = try? AVCaptureDeviceInput(device: device) else {
            fatalError("Could not make input")
        }
        
        session.beginConfiguration()
        
        session.addInput(input)
        
        session.commitConfiguration()
        
        session.startRunning()
    }
    
    public func requestCameraPermission() async -> AVAuthorizationStatus {
        return await withCheckedContinuation({ continuation in
            AVCaptureDevice.requestAccess(for: .video) { [unowned self] didComplete in
                self.authorizationState = AVCaptureDevice.authorizationStatus(for: .video)
                continuation.resume(with: .success(self.authorizationState))
            }
        })
    }
    
}

并将它添加到ViewController这样的:

let preview = AVCaptureVideoPreviewLayer(session: session)
preview.removeFromSuperlayer()  
preview.frame = self.view.bounds      
self.view.layer.insertSublayer(preview, at: 0)

注意, UIViewController 我使用的是进入SwiftUI通过 UIViewControllerRepresentable 协议的一致性。

我已经尝试了一些预设,并发现参数包括会议 .buildInWidtAngleCamera 但似乎无法得到它,以表明完全相机决议? 我的运气在这里的除非我建立它作为一个实际机Mac应用程序?

apple-m1 avfoundation swift video
2021-11-22 21:53:49
1

最好的答案

2

切换到 Optimize interface for Mac 这是在 Target>General>Deployment Info>Next To the Mac checkmark button.

这是有可能识别的摄像头为肖像为

2021-11-23 00:12:21

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................