I am generating a QR code image using the CIQRCodeGenerator filter available from CIFilter. The image is generated fine and when it's displayed I can read the image using AVCaptureSession. However, when I try to scan the QR code using a different platform (Android, BlackBerry, iOS 6) then it doesn't recognize the image. According to Apple's documentation the generated image is compliant with the ISO/IEC 18004:2006 standard. Is the problem that I need something that is compliant with ISO 18004:2000?
Here is the code I'm using to generate the image:
NSData *stringData = [stringToEncode dataUsingEncoding:NSISOLatin1StringEncoding];
CIFilter *qrFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[qrFilter setValue:stringData forKey:@"inputMessage"];
[qrFilter setValue:@"M" forKey:@"inputCorrectionLevel"];
CIImage *qrImage = qrFilter.outputImage;
return [UIImage squareUIImageFromCIImage:qrImage withSize:size];
Here is a sample QR code:
Does anybody know if there is a way to generate a more universally recognized QR code image using CIFilter? I'd really prefer not to go back to using ZXing.
Thank you!
I'm not sure if the slight change makes a difference, but here's a snippet from my recent project that generates a QR code that is scanned from an iPad camera successfully in under a second:
CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[filter setDefaults];
NSData *data = [accountNumber dataUsingEncoding:NSUTF8StringEncoding];
[filter setValue:data forKey:@"inputMessage"];
CIImage *outputImage = [filter outputImage];
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cgImage = [context createCGImage:outputImage
fromRect:[outputImage extent]];
UIImage *barcode = [UIImage imageWithCGImage:cgImage
scale:1.
orientation:UIImageOrientationUp];
// EDIT:
CFRelease(cgImage);