2

I am making a barcode reader app which is free. I am looking for free SDK to decode Datamatrix,QR,Aztec,UPC,EAN barcodes. I have implemented ZBar SDK as per now. Which detects QR,UPC and EAN successfully. I tested This link

Zbar

ZXingOBjC

But none of these are able to detect Aztec properly. With Data Matrix,UPC,EAN and QR i found Redlaser very effective but now its not free.

Now, is there any free SDK available to detect all four barcodes without paying as i want to keep my app free on app store.

Please suggest

P.S I want compatibility of scanner with latest iOS available.

xrnd
  • 1,273
  • 3
  • 21
  • 38
  • 1
    https://code.google.com/p/zxing/ Zebra Crossing? – borrrden Apr 03 '13 at 05:54
  • Sorry, forgot to mention that it says Android / Java (but it has an iOS version in the source) – borrrden Apr 03 '13 at 06:00
  • I agree its a good code, but it doesn't scan Aztec cod and thats where i got stuck before. For rest all it works like a charm but somewhere I am finding it difficult for Aztec. – xrnd Apr 03 '13 at 07:53
  • It says it has Aztec support *right on* the page I linked to. – borrrden Apr 03 '13 at 07:55
  • Yeah it does. For verification i tested android [App](https://play.google.com/store/apps/details?id=com.google.zxing.client.android) and tested Aztec barcode on [this](http://www.barcode1.in/sample-images-2d-barcodes/) page. Sorry, but it didn't scan – xrnd Apr 03 '13 at 08:01
  • Perhaps they didn't include it because it is still in beta. Why don't you try the code out yourself. I saw an Aztec handler class right in there. – borrrden Apr 03 '13 at 08:05
  • Ok i will try the code soon. Thanx – xrnd Apr 03 '13 at 08:18
  • iOS 7 now supports Aztec with AVFoundation Framework – Walter Martin Vargas-Pena Sep 19 '13 at 20:54
  • Thanks Walter Martin for the good info, I will look into it now. – xrnd Sep 23 '13 at 07:02

3 Answers3

1

With some work you could do this using zint. See https://github.com/samlown/zint/blob/master/backend/aztec.c I have used this in an app. Sorry, I am not allowed to share more code than this: include the barcode, aztec, common, font, gs1, rs and bmp classes Then put the code below in a seperate class

void dataProviderReleased (void *info, const void *data, size_t size) {
    struct barcode_symbol *my_symbol = info;
    Barcode_Delete(my_symbol);
}

+ (UIImage *)aztecBarcodeImageFromString:(NSString *)s scale:(CGFloat)scale {
    UIImage *image = nil;
    int errorCode = 0;
    struct barcode_symbol *my_symbol;

    if (s == nil) {
        return nil;
    }

    unsigned char *unicodeCharPtr = (unsigned char *)[s cStringUsingEncoding:NSUTF8StringEncoding];

    LogInfo(@"Creating barcode image for string: %@", s);

    my_symbol = Barcode_Create();

    my_symbol->output_options = 0;

    //my_symbol->output_options = BARCODE_BOX; //For a box around the bar code
    my_symbol->scale = scale;
    my_symbol->symbology = BARCODE_AZTEC;

    my_symbol->input_mode = UNICODE_MODE;

    errorCode = Barcode_Encode(my_symbol, unicodeCharPtr, 0);

    if (errorCode == 0) {
        errorCode = Barcode_Buffer(my_symbol, 0);

        if (errorCode == 0) {

            int numberOfComponents = 3;
            long imgSizePerRow = numberOfComponents * my_symbol->bitmap_width;
            long imgSize = imgSizePerRow * my_symbol->bitmap_height;

            CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

            //The dataProviderReleased method is responsible for deallocating the ZBarCode with the corresponding image data
            CGDataProviderRef providerRef = CGDataProviderCreateWithData(my_symbol, my_symbol->bitmap, imgSize, dataProviderReleased);

            CGImageRef imageRef = CGImageCreate(my_symbol->bitmap_width, my_symbol->bitmap_height, 8, numberOfComponents * 8, 
                                                imgSizePerRow, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaNone, 
                                                providerRef, NULL, NO, kCGRenderingIntentDefault);

            image = [UIImage imageWithCGImage:imageRef];

            CGColorSpaceRelease(colorSpace);
            CGDataProviderRelease(providerRef);
            CGImageRelease(imageRef);
        } else {
            LogWarn(@"Could not buffer barcode, error=%d", errorCode);
            Barcode_Delete(my_symbol);
        }

    } else {
        LogWarn(@"Could not encode barcode, error=%d", errorCode);
        Barcode_Delete(my_symbol);
    }

    return image;
}
Edwin Vermeer
  • 13,017
  • 2
  • 34
  • 58
  • Well i understand that you cant share the code but it will help if you can guide as how to use the aztec code. These files looks helpful but no example to understand how to use. – xrnd Apr 03 '13 at 07:51
1

You scan customize the ZBar Scanner like set some more Symbology like this

-(void)scanProductBarCode
{
    ZBarReaderViewController *reader = [ZBarReaderViewController new];
    reader.readerDelegate = self;

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        reader.supportedOrientationsMask = ZBarOrientationMaskLandscape;
    else
        reader.supportedOrientationsMask = ZBarOrientationMaskPortrait;

    ZBarImageScanner *scanner = reader.scanner;
    [scanner setSymbology: ZBAR_UPCA config: ZBAR_CFG_ENABLE to: 1];
    [scanner setSymbology: ZBAR_CODE39 config: ZBAR_CFG_ADD_CHECK to: 0];
    [scanner setSymbology:ZBAR_QRCODE config:ZBAR_CFG_ADD_CHECK to:1];
    [scanner setSymbology:ZBAR_EAN13 config:ZBAR_CFG_ADD_CHECK to:1];

    [self presentModalViewController:reader animated:YES];
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Ganapathy
  • 4,594
  • 5
  • 23
  • 41
  • I agree with you on this suggestion, ZBar works realy great with EAN,UPC and QR but when it comes to Datamatrix and Eztec i did not find it working. Your settings work fine.there are no Symbols for Eztec and Datamatrix in Zbar so this isn't useful. – xrnd Apr 03 '13 at 07:44
0

These days you can use AVFoundation for scanning barcodes, and has support for all the barcode types you mentioned in your question.

A quick tutorial: Building a Barcode and QR Code Reader in Swift 3 and Xcode 8

Nick Toumpelis
  • 2,717
  • 22
  • 38