Ios AVCaptureSession扫描特定帧中的QRCode

Ios AVCaptureSession扫描特定帧中的QRCode,ios,avcapturesession,Ios,Avcapturesession,我需要做的是做一个扫描仪来获取QRCode值 我遵循苹果的开发者文档,使用AVCaptureDevice、AVCaptureSession、AVCaptureDeviceInput、AVCaptureVideoPreviewLayer、AVCaptureMetadataOutput让它工作 _videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 目前,我成功地获得了qrcode,但如果相机中有两

我需要做的是做一个扫描仪来获取QRCode值

我遵循苹果的开发者文档,使用AVCaptureDevice、AVCaptureSession、AVCaptureDeviceInput、AVCaptureVideoPreviewLayer、AVCaptureMetadataOutput让它工作

_videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
目前,我成功地获得了qrcode,但如果相机中有两个或更多qrcode,我们将获得多个qrcode,因此我只想扫描屏幕上的特定帧,例如CGRectMake{100,100,200,200},以确保处理后只有一个qrcode

那么,如何在AVCaptureDeviceInput中指定所需的帧呢


非常感谢

使用rectOfInterest属性

AVCaptureMetadataOutput *metaDataOutput = [[ AVCaptureMetadataOutput alloc] init];
metaDataOutput.rectOfInterest = CGRectMake(0, 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, 0, 1, 1).  Metadata objects whose bounds do not intersect with the rectOfInterest will not be returned.