top of page
  • Writer's pictureRuben van Breda

IOS AVKit

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

}

}


3 views0 comments

Recent Posts

See All

Comments


bottom of page