nuteron
nuteron

Reputation: 541

How can I scan the following 2-D barcode using the AVFoundation framework in iOS 7?

I need to scan 2-D barcodes in iOS, like the following:

This is a sample 2d barcode

I tried the zbar framework but that didn't seem to work for these barcodes. Now I am trying to use the built-in AVFoundation framework in iOS 7. That works fantastically for 1-D barcodes whose AVObject type is AVMetadataObjectTypeEAN13Code, and QRCodes of type AVMetadataObjectTypeQRCode, but I am not able to scan 2D bar codes.

Is there any specific object type for 2D barcodes?

Upvotes: 1

Views: 1308

Answers (1)

Brad Larson
Brad Larson

Reputation: 170317

The particular type of 2-D barcode you're showing there is called a PDF417 barcode. AV Foundation also has the ability to scan those, as of iOS 7:

PDF417 scanning example

You need to use AVMetadataObjectTypePDF417Code to read the above, like in my image, for example by modifying Apple's QRchestra example with the following line:

[[self metadataOutput] setMetadataObjectTypes:[NSArray arrayWithObjects:AVMetadataObjectTypePDF417Code, nil]];

and then logging the result to the screen like I did.

Upvotes: 1

Related Questions