แสดงเต็มความกว้างของกล้องจากแมคกล้องตอนที่วิ่งผ่านทางโปรแกรแมควเร่งปฏิกิริยา

0

คำถาม

ฉันรู้ว่าของฉัน Macbook นเว็บแคมมีสนามกว้างของมุมมอง ตอนที่ฉันเปิด Quicktime โปรแกรและเลือกของฉัน MacBooks กล้องเหมือนำเข้าข้อมูลฉันเห็นว่าดีออกจะกว้างภาพวิดีโอแบบนี้

enter image description here

ตอนนี้ฉันต้องการ iOS แอ๊ปซึ่งฉันกำลังใช้แมคนตัวเร่งปฎิกริยา นี่คือสร้างรหัสผมจะได้ใช้.

enter image description here

ตอนที่ฉันวิ่งนี้แอ๊ปฉันสำคัญ cropped เวอร์ชั่นของภาพถ่ายวิดิโอจากเว็บแคมเธอบอกให้ผมรอที่นี่

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 โพรโทคอล conformance.

ฉันพยายามเป็นจำนวนของชุดสำเร็จกับการค้นวาระการใช้งานรวมถึงค่าพารามิเตอร์ .buildInWidtAngleCamera แต่ไม่สามารถดูเหมือนจะเอามันเพื่อให้มีการแสดงเต็มไปด้วยกล้องความละเอียด? ฉันออกจากความโชคอยู่ที่นี่นอกจากฉันสร้างมันเป็นจริงเป็นชนพื้นเมืองที่แมคนโปรแกรม?

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.

มันก็ดูเหมือนระบุตัวตนของกล้องเป็นแนวตั้งสำหรับ iPad

2021-11-23 00:12:21

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

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

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่