View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
#AVCAPTUREMETADATAOUTPUT #BARCODE SCANNING #IOS7 #PROGRAMMING

One new feature in iOS7 which didn’t get announced anywhere (as far as I can tell anyway) if the ability to read barcodes.

There’s a new output for AVCapture called AVCaptureMetadataOutput - this supports a large number of supported formats including 1D and 2D barcodes.

Getting it up and running is pretty simple. Do the normal code for capturing output from the camera and then for the output do the following:

AVCaptureMetadataOutput *output = [[AVCaptureMetadataOutput alloc] 
                                           init];
[self.session addOutput:output];

// see what types are supported (do this after adding otherwise the output reports nothing supported
NSSet *potentialDataTypes = [NSSet setWithArray:@[
                  AVMetadataObjectTypeAztecCode,
                  AVMetadataObjectTypeCode128Code,
                  AVMetadataObjectTypeCode39Code,
                  AVMetadataObjectTypeCode39Mod43Code,
                  AVMetadataObjectTypeCode93Code,
                  AVMetadataObjectTypeEAN13Code,
                  AVMetadataObjectTypeEAN8Code,
                  AVMetadataObjectTypePDF417Code,
                  AVMetadataObjectTypeQRCode,
                  AVMetadataObjectTypeUPCECode]];

NSMutableArray *supportedMetaDataTypes = 
                            [NSMutableArray array];
for(NSString *availableMetadataObject in 
                  output.availableMetadataObjectTypes) {
    if([potentialDataTypes 
             containsObject:availableMetadataObject]) {
        [supportedMetaDataTypes 
                addObject:availableMetadataObject];
    }
}

[output setMetadataObjectTypes:supportedMetaDataTypes];

// Get called back everytime something is recognised
[output setMetadataObjectsDelegate:self 
                             queue:dispatch_get_main_queue()];

You’ll then get called back on this method with array of AVMetadataMachineReadableCodeObject

- (void)   captureOutput:(AVCaptureOutput *)captureOutput 
didOutputMetadataObjects:(NSArray *)metadataObjects 
          fromConnection:(AVCaptureConnection *)connection {
    for(AVMetadataMachineReadableCodeObject *recognizedObject in metadataObjects) {
        NSLog(@"%@", recognizedObject.stringValue);
    }
}

I’ve created a quick demo project available here: https://github.com/cgreening/BarCodeExample.

#AVCAPTUREMETADATAOUTPUT #BARCODE SCANNING #IOS7 #PROGRAMMING

Related Posts

Augmented reality on the iPhone with iOS4.0 - Hey guys! Just updated my earlier blog post on creating Augmented Reality (AR) on iPhones using the new iOS4.0 features. I’ve also moved away from the 'UIGetScreenImage' function as it’s no longer supported. Now, we access the camera using the AV Foundation framework with the help of AVCaptureSession. As always, you're free to download and fiddle with my code available in this blog. Happy Programming!
Augmented Reality on the iPhone - how to - Hey there tech enthusiasts! So, you used to rely on my old methods for employing augmented reality on an iPhone? Well, those days are past. With the release of iOS4, accessing the camera has become a breeze. Check out my latest blog post where I share the specially updated code that works seamlessly with iOS4.
Vision Kit and CoreML - In this technical tutorial, we walk through the process of wiring up the iPhone's camera to CoreML using Vision Kit, allowing us to run machine learning models against the camera input. We outline the necessary steps in creating a new Xcode project; capturing video frames; using AVFoundation, Vision, and CoreML; and dissecting the video frames using Vision magic. We also illustrate the process of running our Vision requests and displaying the expected outputs.

Related Videos

Vision framework and CoreML - Discover the seamless integration of Apple's Vision framework with Core ML for object identification in this astounding demonstration, and lock onto the project at GitHub.
Augmented Reality iPhone Sudoku Grab - Experience real-time augmented reality capture with the new version of Sudoku Grab! Learn to build your own app with detailed guidance provided in the linked article.
Wio Terminal Audio Visualizer - Learn about porting an audio monitor to the WiiO terminal, featuring a built-in microphone, gyroscope, accelerometer, light sensor, and infrared emitter. Check out the simple base class used for the display and the efficient template class implementation to swap out between two different display libraries.
ICS-43434 A replacement for the old INMP441 - Ideal for the ESP32 - Learn how to use the latest ICS-43434 I2S MEMS microphone for your audio projects and get insights on the PCB design process, including circuit diagrams and layout!
256 Shades of Grey – Adventures in Image Processing - In this enlightening video, I delve into the deep and fascinating world of image processing. Forget everything you thought you knew about pixels – they’re not squares or rectangles and they definitely aren’t discs. All pixels are, my friends, are point samples, each capturing brightness or color at a particular position. Curious to know how to manipulate them? I also unravel this mysterious tapestry, familiarizing you with the technicalities of grayscale, RGB, HSB, YUV, and a fleeting mention of CMYK. And if you think that's all, hold tight! Did you know we could apply Fourier transforms, akin to graphic equalisers used in audio, to our good old two-dimensional images? Strap in as I guide you through this potentially overwhelming realm with a pinch of humor, lots of simplicity, and oodles of practical examples.
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening


Published

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts