首页 > 其他 > 详细

识别图片中的二维码

时间:2018-04-10 20:52:18      阅读:157      评论:0      收藏:0      [点我收藏+]

 //截图 再读取

        UIGraphicsBeginImageContextWithOptions(currentImageView.bounds.size, YES, 0);//currentImageView 图片VIEW

        

        CGContextRef context = UIGraphicsGetCurrentContext();

        [self.layer renderInContext:context];

        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

        //识别二维码

        CIImage *ciImage = [[CIImage alloc] initWithCGImage:image.CGImage options:nil];

        CIContext *ciContext = [CIContext contextWithOptions:@{kCIContextUseSoftwareRenderer : @(YES)}]; // 软件渲染

        CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:ciContext options:@{CIDetectorAccuracy : CIDetectorAccuracyHigh}];// 二维码识别

        NSArray *features = [detector featuresInImage:ciImage];//手机连接Xcode运行到这就出问题 但是在手机上 运行没问题

        for (CIQRCodeFeature *feature in features) {

            NSLog(@"msg = %@",feature.messageString); // 打印二维码中的信息

            //对结果进行处理

}

 

识别图片中的二维码

原文:https://www.cnblogs.com/xiaodeng90/p/8782675.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!