Senseful
Senseful

Reputation: 91761

Constants for AVCaptureMetadataOutput's metadataObjectTypes property?

When using AVFoundation to detect features (e.g. faces or barcodes) in an image, you must call a line such as:

AVCaptureMetadataOutput *metadataOutput = ...;
metadataOutput.metadataObjectTypes = metadataOutput.availableMetadataObjectTypes;

Examining availableMetadataObjectTypes shows the following strings:

face,
"org.gs1.UPC-E",
"org.iso.Code39",
"org.iso.Code39Mod43",
"org.gs1.EAN-13",
"org.gs1.EAN-8",
"com.intermec.Code93",
"org.iso.Code128",
"org.iso.PDF417",
"org.iso.QRCode",
"org.iso.Aztec"

If I am writing a barcode scanning app, I don't want the framework to be looking for faces, so instead of passing metadataOutput.availableMetadataObjectTypes, I want to pass specific barcodes to look for. Rather than using these hard-coded strings, I was hoping they were defined as constants somewhere.

Do they exist anywhere in the framework, or must I use hard-coded strings?

Upvotes: 1

Views: 3669

Answers (1)

lxt
lxt

Reputation: 31304

There are constants for the various barcode types, just in the AVMetadataMachineReadableCodeObject class (full list here).

So you can do something like this:

metadataOutput.metadataObjectType = @[AVMetadataObjectTypeQRCode, AVMetadataObjectTypeEAN13Code];

Upvotes: 5

Related Questions