Constants for AVCaptureMetadataOutput's metadataObjectTypes property?

不问归期 提交于 2019-12-11 12:54:11

问题


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?


回答1:


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];


来源:https://stackoverflow.com/questions/22187919/constants-for-avcapturemetadataoutputs-metadataobjecttypes-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!