Real Time Face Tracking with Camera on Swift 3
https://bethedev.blogspot.com/2017/09/real-time-face-tracking-with-camera-on.html
FaceTracking
An example app with AVFoundation camera support and face tracking written in Swift 3.0.
Source and Sample Project file: GitHub
Below an example how it works.
Store image on Device
Calling below function will help you to store an image on the device.
func saveToCamera() { if let videoConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) { stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { (CMSampleBuffer, Error) in if let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(CMSampleBuffer) { if let cameraImage = UIImage(data: imageData) { UIImageWriteToSavedPhotosAlbum(cameraImage, nil, nil, nil) } } }) } }
If this code was helpful, I would love to hear from you or If you have any questions please post your comments below.
Thank you!