Skip to content

Instantly share code, notes, and snippets.

@Danesz
Created May 14, 2020 21:47
Show Gist options
  • Save Danesz/671f19046096115fa591d92011d36816 to your computer and use it in GitHub Desktop.
Save Danesz/671f19046096115fa591d92011d36816 to your computer and use it in GitHub Desktop.
CameraViewControllerHidden.swift - init
// ...
do {
deviceInput = try AVCaptureDeviceInput(device: captureDevice)
guard deviceInput != nil else {
print("error: can't get deviceInput")
return
}
if self.session.canAddInput(deviceInput){
self.session.addInput(deviceInput)
}
stillImageOutput = AVCapturePhotoOutput()
if session.canAddOutput(stillImageOutput) {
session.addOutput(self.stillImageOutput)
}
// we can also attach videoDataOutput from the previous example to get all the video frames
// but for now image capturing is enough
// and whoopsie, we forgot the preview :(
session.startRunning()
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment