Search code examples
iosqr-codeavmetadataitem

QR code ios 7 AVMetadataObject


I Have problem with detect where is qr code.

I need draw border around it.

I use AVMetadataObject bezierpath, but it dont work.

Please help me.

- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputMetadataObjects:(NSArray *)metadataObjects
       fromConnection:(AVCaptureConnection *)connection
{
    for (AVMetadataObject *metadata in metadataObjects)
    {
            AnimationView *cv = [[AnimationView alloc]initWithFrame:self.livevideo.bounds]; //creat an instance of your custom view
        [cv setBackgroundColor:[UIColor clearColor]];



        NSLog(@"%f",metadata.accessibilityPath.accessibilityActivationPoint.x);

        [location addSubview:cv];


        if ([metadata.type isEqualToString:AVMetadataObjectTypeEAN13Code])
        {

        }
        else if ([metadata.type isEqualToString:AVMetadataObjectTypeUPCECode])
        {

        }
        else if ([metadata.type isEqualToString:AVMetadataObjectTypeEAN8Code])
        {

        }
        else if ([metadata.type isEqualToString:AVMetadataObjectTypeQRCode])
        {

        }
    }
}

Solution

  • You will need to use the corners property from AVMetadataMachineReadableCodeObject to draw a perspective box around the detected code.

    See my example at https://github.com/werner77/WECodeScanner