Live Video Face Masking on iOS

A great post to live video processing

Chris Cavanagh's Blog

Face detection has been possible for some time on iOS thanks to libraries like OpenCV. The CIDetector class introduced in iOS 5 made it a standard feature. Since iOS 7 it can also detect smiles and eye blinks Smile

With iOS 6, AV Foundation gained AVCaptureMetadataOutput, allowing face detection to be included in the capture pipeline (in iOS 7 it also supports barcode scanning).

Here’s how you could use that to perform face masking on live video:


First thing to do is get the capture session set up:

 AVCaptureSession *captureSession = [AVCaptureSession new]; [captureSession beginConfiguration]; NSError *error; // Input device AVCaptureDevice *captureDevice = [self frontOrDefaultCamera]; AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error]; if ( [captureSession canAddInput:deviceInput] ) { [captureSession addInput:deviceInput]; } if ( [captureSession canSetSessionPreset:AVCaptureSessionPresetHigh] ) { captureSession.sessionPreset = AVCaptureSessionPresetHigh; } // Video data output AVCaptureVideoDataOutput *videoDataOutput = [self createVideoDataOutput]; if ( [captureSession canAddOutput:videoDataOutput] ) { [captureSession addOutput:videoDataOutput]; AVCaptureConnection *connection…

View original post 511 more words


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

Up ↑

%d bloggers like this: