IOS AVKit
- Ruben van Breda
- Sep 3, 2020
- 1 min read
Getting the camera working
Import UIKit
import AVKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//Here we start up the camera
let captureSession = AVCaptureSession()
guard let captureDevice = AVCaptureDevice.default(for: .video) else {return}
guard let input = try? AVCaptureDeviceInput(device: captureDevice) else {return}
captureSession.addInput(input)
captureSession.startRunning()
let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
view.layer.addSublayer(previewLayer)
previewLayer.frame = view.frame
}
}
コメント