What I need todo is make a Scanner to get the QRCode values.
And I followed the Apple developer documents, use AVCaptureDevice, AVCaptureSession, AVCaptureDeviceInput, AVCaptureVideoPreviewLayer, AVCaptureMetadataOutput to get it works.
_videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
Currently, I get the qrcode successfully, but if there are two or more qrcodes in the camera, we will get several qrcode, so I just want to scan the specific frame on the screen, for example CGRectMake{100, 100, 200, 200}, to make sure there is only one qrcode once we processed.
So, how can we specify the frame we want in the AVCaptureDeviceInput.
Thanks a lot!
Use the rectOfInterest property.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With