I have a UIViewController
in which I use AVCaptureSession
to show the camera and it is working just fine and fast. I placed a UIButton
object on top of this camera view and added a IBAction
for the button.
This is how it looks like right now:
Now I want to get the picture of the current camera view when the user taps the button:
@IBAction func takePicture(sender: AnyObject) {
// omg, what do do?!
}
I have no idea whatsoever on how I can do that. I imagined there could have been something like:
let captureSession = AVCaptureSession()
var myDearPicture = captureSession.takePicture() as UIImage // something like it?
The full link for the controller code is here https://gist.github.com/rodrigoalvesvieira/392d683435ee29305059, hope it helps
As
AVCaptureStillImageOutput
is deprecated, I created another Swift example of usingAVCaptureSession
andAVCapturePhotoOutput
in iOS 10. Check this out.AVCaptureSession Sample
UIImagePickerController Sample