🌈 ESP32-S3 Rainbow: ZX Spectrum Emulator Board! Get it on Crowd Supply →
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

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.

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!
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.
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.
Cropping the results from UIImagePickerController - Wrestled with UIImagePickerControllerCropRect today for cropping images. Some of the codes out there were ridiculously long winded, so I took a stab at whittling it down myself. Safely arrived at a streamlined solution that dealt with the size of image, the crop rect and graphics context. Also worked in a neat bit on image orientation. Law of parsimony victorious!

Related Videos

ESP32 SD Card Speedup With a Couple of Lines of Code - In this video, we explore the disappointingly slow data writing speed of the ESP32 when reading and writing to an SD card in our TinyTV project. With 500 kilobytes/sec reading and a dismal 270 kilobytes/sec writing, we embark on an adventure to find a solution. After ditching the Arduino code in favor of IDF functions, we discover incredible improvements. Seeing potential risks, I propose a truly bonkers plan: using a IC to interface SD cards with USB with a USB multiplexer switch and another switch to alternate between ESP32 and the GL823. This could be a total disaster, but I'm game for the challenge. Stay tuned to see if it works out!
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.
My ESP32S3 Thinks It's a WebCam! - I turned a vanilla ESP32-S3 dev board into a USB UVC webcam that doesn’t use a camera at all—first streaming a static test card, then an animated GIF, and finally a real-time Pong game. The ESP32 pre-decodes GIF frames to RGB, JPEG-encodes them, and streams MJPEG, and for the live game it renders to a framebuffer, JPEG-encodes in ~23 ms, and just about hits 30 fps. There’s room to optimize (dual-core draw/encode), and this approach is great for dashboards, sensor visualizations, or testing video pipelines. Shout out to PCBWay for the boards—they turned out great.
Streaming Video and Audio over WiFi with the ESP32 - In this video, we dive into a hardware hack combining several components to create my version of the TinyTV, complete with a remote control, and video streaming over Wi-Fi. We challenge the speed of image display, using different libraries and tweaking performance for optimal results. We explore Motion JPEG or MJPEG to decode and draw images quickly, and even reach about 28 frames per second. We also catered audio using 8-bit PCM data at 16kHz, and deal with syncing both video and audio streams. Finally, we add some interactive elements allowing us to change channels and control volumes, with a classic static animation thrown in for good measure. There's a few hiccups along the way, but that's part of the fun, right?
I Turned an ESP32 into a Thermal USB Webcam - Last time I made an ESP32 pretend to be a webcam; this time it’s a real USB UVC cam streaming MJPEG. Then I go further: I bolt on a tiny 32x24 infrared sensor, scale it up to 320x240 with nearest-neighbor or bilinear, JPEG it, and stream it like any normal webcam. Along the way I show why ESP32-CAM won’t work (no native USB), dive into I2C gremlins (run a scanner first, check pull-ups), and fix a flaky 3.3V regulator solder job. Quick hardware tour: onboard 2.2K pull-ups, ME6212 LDO, and an AT32F415 MCU. Audio can wait—today’s all about making thermal video look good over UVC.
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