AVCaptureSession scans QRCode in a specific frame

I need todo make a scanner to get QRCode values.

And I followed the Apple developer docs, used AVCaptureDevice, AVCaptureSession, AVCaptureDeviceInput, AVCaptureVideoPreviewLayer, AVCaptureMetadataOutput to make them work.

_videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

I am currently receiving qrcode successfully, but if there are two or more qrcodes in the camera, we will get several qrcode, so I just want to scan a specific frame on the screen, for example CGRectMake {100, 100, 200, 200}, to make sure there is only one processed by qrcode.

So, how can we specify the desired frame in AVCaptureDeviceInput.

Thank you so much!

+4
source share
1 answer

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 rectangle of interest for each frame of video.  
    The rectangle 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.
+4

All Articles