Question

In my application, Zbar is decoding perfectly. But the problem is Zbar can decode both QR code and bar code. So after decoding, how do I get the type of Encoding Style?

Was it helpful?

Solution

There are return codes for type in ZBarSymbol. You will be looking for ZBAR_QRCODE for QR codes

ZBarSymbol documentation

Something like this should help you to get the symbol out:

- (void) readerView: (ZBarReaderView*) view didReadSymbols: (ZBarSymbolSet*) syms  fromImage: (UIImage*) img 
{
    //do something useful with results and display resultText in resultViewController
    for(ZBarSymbol *sym in syms) 
    {
        imageResult3.image = img; 
        resultText.text = sym.typeName;
        resultText.text =  [ resultText.text stringByAppendingString:@" - " ];
        resultText.text =  [ resultText.text stringByAppendingString:sym.data ]; 

    }
}

OTHER TIPS

What i did was,

- (void) imagePickerController: (UIImagePickerController*) reader  didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage];
    ZBarImage *zImage = [[ZBarImage alloc] initWithCGImage:image.CGImage];
    ZBarImageScanner *scanner = [[ZBarImageScanner alloc] init];
    [scanner setSymbology: ZBAR_I25
                        config: ZBAR_CFG_ENABLE
                        to: 0];
    [scanner scanImage:zImage];
    ZBarSymbolSet *set = [scanner results];

    ZBarSymbol *symbol = nil;
    for (symbol in set)
        break;
    codeType.text = symbol.typeName
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top