iOS查看图片中是否包含二维码

UIImage *pickedImage = selectPhotos[0];
CIImage *detectImage = [CIImage imageWithData:UIImagePNGRepresentation(pickedImage)];
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy: CIDetectorAccuracyLow}];
CIQRCodeFeature *feature = (CIQRCodeFeature *)[detector featuresInImage:detectImage options:nil].firstObject;
if (feature.messageString) {
DLog(@"存在QR");
}else{
DLog(@"不存在QR");
}

你可能感兴趣的:(iOS查看图片中是否包含二维码)