Chapter 3. Scanning barcodes

This chapter covers

  • How to scan barcodes with AV Foundation’s metadata detector
  • Optimizing scanning performance and user experience
  • UI considerations for different kinds of barcode-scanning scenarios
  • Navigating around common barcode-scanning pitfalls

The previous chapter introduced you to capturing media with AV Foundation. You learned about the components of AV Foundation that allow you to take a video stream from the device’s cameras and display it in a preview layer and capture media to files.

In this chapter you’ll learn how to add the AV Foundation metadata detector to this video stream, and have it report back about barcodes it has detected.

3.1. Metadata detection in AV Foundation

In chapter 2 you built a camera app and encountered one kind of AV capture output, AVCaptureStillImageOutput. Other outputs allow you to write to audio or video files, and they’re set up the same way as the still image output.

For scanning barcodes, you’ll use the AVCaptureMetadataOutput component. As you can infer from the name, this is also part of AV media capture, it’s an output, and it has something to do with metadata. This isn’t data that describes actual pixels or audio samples. Rather it’s metadata about the picture, describing things that you can see in the video image.

3.2. Building a QR Code scanner

3.3. Summary

sitemap