CIDetector不适用于QR图像

时间:2017-06-27 12:59:35

标签: objective-c iphone qr-code ciimage cidetector

我使用以下代码从包含QR码的图库中获取图像。我面临的问题是在某些设备中检测到qr代码,而在其他设备中检测不到。     从它的外观来看,我诊断的是iOS 10.7及更低版本的设备没有检测到QR码,而从iOS 10.7更高版本,代码工作正常。     如何让它在iOS 10.7和更小的设备下运行。我没有找到任何帮助。如果任何机构有任何关于此的链接或解决方案,将不胜感激。提前致谢![Unscanable picture] 1     我还附上了必须扫描的图像。

使用的代码:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

    BOOL qrcodedetected = NO;
    [picker dismissViewControllerAnimated:YES completion:NULL];

    UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];       
    // QRCode detector
    NSDictionary *detectorOptions = @{ CIDetectorAccuracy : CIDetectorAccuracyHigh };
    CIDetector *faceDetector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:detectorOptions];
    NSArray *features = [faceDetector featuresInImage:chosenImage.CIImage];
    CIQRCodeFeature *faceFeature;
    for(faceFeature in features)
    {
        qrcodedetected = YES;
        self.decodedstr = [NSString stringWithFormat:@"%@",faceFeature.messageString];
        break;
    }
}

0 个答案:

没有答案