简体   繁体   English

条码扫描排除AVmetadaTypeFace

[英]Barcode scanning exclude AVmetadaTypeFace

I'm developing a barcode scanner app using AVFoundation.我正在使用 AVFoundation 开发条形码扫描仪应用程序。 My app successfully captures barcode data but it crash when detect FaceObjectType.我的应用程序成功捕获条码数据,但在检测到 FaceObjectType 时崩溃。 How can we exclude this type from being detected to prevent crashing?我们如何排除这种类型的检测以防止崩溃?

I'm using this:我正在使用这个:

captureMetadataOutput.metadataObjectTypes = [captureMetadataOutput availableMetadataObjectTypes];

Its a bit late, but I think it will help someone who have the same issue.有点晚了,但我认为它会帮助有同样问题的人。 For Preventing crash, you need to handle the AVMetadataObject( https://developer.apple.com/documentation/avfoundation/avmetadataobject ), So my suggestion for this is as below (swift 3.0)为了防止崩溃,您需要处理 AVMetadataObject( https://developer.apple.com/documentation/avfoundation/avmetadataobject ),所以我对此的建议如下(swift 3.0)

for metadataObject in metadataObjects {
     if (metadataObject as AnyObject).type == AVMetadataObjectTypeFace {
                return
            }
        }

You will fix the supported object type by using this您将通过使用此修复支持的对象类型

  NSArray *supportedType =[NSArray arrayWithObjects:
                         AVMetadataObjectTypeCode39Code,
                         AVMetadataObjectTypeCode39Mod43Code,
                         AVMetadataObjectTypeCode93Code,
                         AVMetadataObjectTypeCode128Code,
                         AVMetadataObjectTypeEAN8Code,
                         AVMetadataObjectTypeEAN13Code,
                         AVMetadataObjectTypeAztecCode,
                         AVMetadataObjectTypePDF417Code,
                         AVMetadataObjectTypeQRCode, nil];

captureMetadataOutput.metadataObjectTypes = supportedType;

instead of而不是

captureMetadataOutput.metadataObjectTypes = [captureMetadataOutput availableMetadataObjectTypes];

This will help.这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM