1. 简单说下需求 本地图片中包含二维码包含在本地相册中 从相册中选中该图片并识别到二维码中的有效信息
- 废话补多少贴一段有效的代码 选取本地相册中的图片方法这里就不再讲了
UIImage *pickImage = assets.firstObject;
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy: CIDetectorAccuracyHigh}];
NSArray *features = [detector featuresInImage:[CIImage imageWithData:UIImagePNGRepresentation(pickImage)]];
if (features.count > 0) {
CIQRCodeFeature *feature = features[0];
NSString *stringValue = feature.messageString;
DLog(@"识别的最终结果===%@",stringValue);
} else {
DLog(@"未识别的具体单号");
[self showMsg:@"未识别到具体内容"];
}
这里试试识别的后半部分 我是拿到UIImage对象放到当前对象中直接识别的