Incept Development



{application software design and development}

Machine Readable Code and Face Recognition Example iOS 7

Pre iOS 7 if we wanted to scan machine readable codes i.e. QR Codes, Bar Codes etc. we had to rely on 3rd party C++ libraries. Even though libraries like ZXing are great they are still an overload, hard to compile, and require refractoring for every new iOS. With iOS 7 Apple has added the ability to extract metadata from machine readable codes directly to AVFoundation. Ivan Djeferov has written a great example which can be used to scan QRCode metadata and Face Recognition. It really boils down to reading output from:



#pragma mark - AVMetadataObjectsDelegate

- (
void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputMetadataObjects:(
NSArray *)metadataObjects
fromConnection:(
AVCaptureConnection *)connection
{
for (AVMetadataMachineReadableCodeObject *avmmrco in metadataObjects)
{
id callback = ^()
{
if (self.didRecognizeMetadataObject)
{
self.didRecognizeMetadataObject (self,
captureOutput,
connection,
_previewLayer,
avmmrco);
}
};

if (!self.callbackQueue)
{
dispatch_async(dispatch_get_main_queue(), callback);
}
else
{
dispatch_async(self.callbackQueue, callback);
}
}
}



Apple allows up to 4 metadata objects at the same time. If machine readable codes are detected it will output an array with metadata objects of type: AVMetadataMachineReadableCodeObject. Those contain stringValue, codeType, bounds and corners. You can download Xcode example below:

Download Machine Readable Code and Face Recognition Example iOS 7

The code requires advanced iOS programming knowledge. It is based on:

Camera Overlay:
http://www.shinobicontrols.com/blog/posts/2013/10/11/ios7-day-by-day-day-16-decoding-qr-codes-with-avfoundation/

AVFoundation Example:

https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html

img_2850

Open Source

Unknown

Welcome! Tutorials page on our website is an attempt to give back to the open source community and help people write better code. Please check back soon as we will be filling up this section with examples we have created, collected or come across.
Dec 2013
Sep 2013
©2013 Incept Development Contact Us