I want to scan a static UIImage using Zbar sdk, it gives error i.e. ZBarSymbol is Null
I also checked
ZBarReaderController: UIImagePickerCon
A stripped-down generic version of Baig's wonderful solution. Change ZBAR_I25 to desired code format.
- (NSString *)findQRCode:(UIImage *)inputUIImage
{
ZBarReaderController *imageReader = [ZBarReaderController new];
[imageReader.scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
id <NSFastEnumeration> results = [imageReader scanImage:inputUIImage.CGImage];
ZBarSymbol *sym = nil;
for(sym in results) {
break;
} // Get only last symbol
if (!sym) {
NSLog(@"No barcode found");
return nil;
}
NSLog(@"Found barcode! quality: %d string: %@", sym.quality, sym.data);
return sym.data;
}
Got solution:
- (NSString *)scanForQR:(UIImage *)image
{
ZBarReaderController *imageReader = [ZBarReaderController new];
[imageReader.scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
id <NSFastEnumeration> results = [imageReader scanImage:image.CGImage];
ZBarSymbol *sym = nil;
for(sym in results) {
break;
} // Get only last symbol
if (!sym) {
NSLog(@"No barcode found");
return nil;
}
NSLog(@"Found barcode! quality: %d string: %@", sym.quality, sym.data);
return sym.data;
}