美文网首页iOS经验总结
iOS 系统识别相册里面的二维码

iOS 系统识别相册里面的二维码

作者: 晴朗Nic | 来源:发表于2021-03-18 20:04 被阅读0次
    ///系统识别相册二维码
    +(NSString *)stringValueFrom:(UIImage *)image{
        ///系统识别二维码
        CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy: CIDetectorAccuracyHigh}];
        // 取得识别结果
        NSArray *features = [detector featuresInImage:[CIImage imageWithCGImage:image.CGImage]];
        NSString *resultStr;
        if (features.count == 0) {
            return @"请检查图片是不是二维码";
        }
        for (int index = 0; index < [features count]; index ++) {
            CIQRCodeFeature *feature = [features objectAtIndex:index];
            resultStr = feature.messageString;
        }
        return resultStr;
    }
    
    

    相关文章

      网友评论

        本文标题:iOS 系统识别相册里面的二维码

        本文链接:https://www.haomeiwen.com/subject/srbpcltx.html