iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – AVCaptureSession扫描特定帧中的QRCode大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要的是让扫描仪获取QRCode值.

而我跟着Apple开发者文档,使用AVCaptureDevice,AVCaptureSession,AVCaptureDeviceInput,AVCaptureVideoPreviewLayer,AVCaptureMetadataOutput来使其工作.

_videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

目前,我成功获得了qrcode,但如果相机中有两个或更多qrcodes,我们将获得几个qrcode,所以我只想扫描屏幕上的特定帧,例如CGRectMake {100,100,200,200 },以确保我们处理后只有一个qrcode.

那么,我们如何在AVCaptureDeviceInput中指定我们想要的帧.

非常感谢!

解决方法

使用rectOfInterest属性.

AVCaptureMetadataOutput *MetaDataOutput = [[ AVCaptureMetadataOutput alloc] init];
MetaDataOutput.rectOfInterest = CGRectMake(0,0.5f,0.5f);

 @discussion
    The value of this property is a CGRect that determines the receiver's rectangle of interest for each frame of video.  
    The rectangle's origin is top left and is relative to the coordinate space of the device providing the Metadata.  Specifying 
    a rectOfInterest may improve detection perfoRMANce for certain types of Metadata. The default value of this property is the 
    value CGRectMake(0,1,1).  Metadata objects whose bounds do not intersect with the rectOfInterest will not be returned.

大佬总结

以上是大佬教程为你收集整理的ios – AVCaptureSession扫描特定帧中的QRCode全部内容,希望文章能够帮你解决ios – AVCaptureSession扫描特定帧中的QRCode所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。