httpwwwbethedevcom
324329524619168
Loading...

Real Time Face Tracking with Camera on Swift 3

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!
Swift 395236890930815963

Post a Comment Default Comments Disqus Comments

emo-but-icon

Home item

Follow by Email

Popular Posts

Random Posts