iOS 图片中二维码的识别
作者:
和谐共处 | 来源:发表于
2018-03-02 16:30 被阅读3次- (void)detectorImage:(UIImage *)image{
// CIDetector(CIDetector可用于人脸识别)进行图片解析,从而使我们可以便捷的从相册中获取到二维码
// 声明一个 CIDetector,并设定识别类型 CIDetectorTypeText
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy: CIDetectorAccuracyHigh}];
// 取得识别结果
NSArray *features = [detector featuresInImage:[CIImage imageWithCGImage:image.CGImage]];
if (features.count == 0) {
NSLog(@"暂未识别 - - %@", features);
return;
} else {
for (int index = 0; index < [features count]; index ++) {
CIQRCodeFeature *feature = [features objectAtIndex:index];
NSLog(@"读取二维码数据信息 - - %@", @(feature.bounds));
NSLog(@"读取二维码数据信息2 - - %@", feature.messageString);
}
}
}
本文标题:iOS 图片中二维码的识别
本文链接:https://www.haomeiwen.com/subject/xkwaxftx.html
网友评论