AVCaptureMetadataOutputObjectsDelegate:用來捕捉並輸出數據的方法
在自己的專案裡 extension AVCaptureMetadataOutputObjectsDelegate
設定 AVCaptureSession
實例化一個 AVCaptureSession 物件
captureSession = AVCaptureSession()
透過 AVCaptureDevice 來捕捉相機及其相關屬性
uard let videoCaptureDevice = AVCaptureDevice.default(for: .video) else { return }
let videoInput:AVCaptureDeviceInput
do {
videoInput = try AVCaptureDeviceInput(device: videoCaptureDevice)
} catch {
print(error)
return
}
``
判斷是否可以將 videoInput 加入到 captureSession
f (captureSession?.canAddInput(videoInput) ?? false) {
captureSession?.addInput(videoInput)
} else {
return
}
``
明天將會繼續介紹 AVCaptureMetadataOutputObjectsDelegate 裡的設定
GitHub - AVCaptureVideoPreviewLayerDemo