ios – AVCaptureSession扫描特定帧中的QRCode

ios – AVCaptureSession扫描特定帧中的QRCode,第1张

概述我需要的是让扫描仪获取QRCode值. 而我跟着Apple开发者文档,使用AVCaptureDevice,AVCaptureSession,AVCaptureDeviceInput,AVCaptureVideoPreviewLayer,AVCaptureMetadataOutput来使其工作. _videoDevice = [AVCaptureDevice defaultDeviceWithMed 我需要的是让扫描仪获取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所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1069621.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存