0
votes

I am working on an iOS application and I am interested to embed some already developed and tested barcode scanner into it. I tried zxing but this never extract the numbers out of it. My goal is to scan this image and get 24 characters out of it.

If there is not a already developed thing, I would like to build one myself. How should I start in order to create it from scratch for 1D barcodes initially?

enter image description here

Using zxing I am using this piece of code now.

- (IBAction)scanPressed:(id)sender {

    ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:YES];

    zxing::oned::Code128Reader *code128Reader = new zxing::oned::Code128Reader();
    MultiFormatOneDReader *mfReader = [[MultiFormatOneDReader alloc] initWithReader:code128Reader];
    NSSet *readers = [[NSSet alloc ] initWithObjects:mfReader,nil];
    [mfReader release];

    widController.readers = readers;
    [readers release];

    NSBundle *mainBundle = [NSBundle mainBundle];
    widController.soundToPlay =
    [NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO];
    [self presentModalViewController:widController animated:YES];
    [widController release];
}
3
What is the type of barcode you need to scan? Make sure the library you use is able to scan the specific type of barcode you will be using (this is not an EAN-13 barcode and does not seem to be any other EAN family, so ask yourself first what barcode type and standard is it to then choose an appropriate lib) - AliSoftware
I still need to figure out the type. What do you think if I simply read the characters from this image assuming I just need these 24 numbers. Why may I read the lines and spaces to figure out the number? - Umair A.
Because number recognition is much harder than barcode reading. Barcode are specifically designed to be easier to read, even in bad lighting conditions, different zoom levels, perspective distortion, rotation and much more: they are easy to detect even with other images and text around, and easy to decode whatever the distortion, (they are scale and rotation independant). - AliSoftware
OCR and numbers recognition is much more tricky and random (e.g. "6" and "8" characters will probably look the same for your recognition algorithm), it is more complicated to make them rotation/perspective/distortion/scale-independant and it will have a much higher error rate (especially in bad lightning conditions, or if there is some dust on the image, etc) than barcode reading. - AliSoftware

3 Answers

3
votes

I tried ZXing SDK first but it didn't work. I then tried ZBar SDK which worked just amazingly great.

If in future someone would need the same thing I am going to post the link which helped me make it work.

http://zbar.sourceforge.net/iphone/sdkdoc/tutorial.html

2
votes

If this is a "Code 128" barcode, pay attention of the variant of the code.

For example if using zxing you successfully scanned the code but the decoded values do not match the numbers under the barcode, that's probably because zxing decoded the barcode bytes successfully but didn't render the result using the expected alphabet.

Code 128 exists in three variants:

  • Code 128 A which uses the alphabet "!#$%&'()*+.-/0123456789:;<=>?@ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
  • Code 128 A which uses the wider alphabet "!#$%&'()*+.-/0123456789:;<=>?@ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`` abcdefghijklmnopqrstuvwxyz{|}~
  • Code 128 C which encodes numbers 0-9

Maybe zxing returns the 128-A or 128-B interpretation of the barcode and not the 128-C variant? In such cases it would mean that the scanning works correctly but you may force the barcode format so it can interpret it right.

1
votes

Maybe I'm wrong about this the zxing code bases for iphone only allows for QR codes. From the website site http://code.google.com/p/zxing/

There are also additional modules which are contributed and/or intermittently maintained:

zxing.appspot.com: The source behind our web-based barcode generator
csharp: Partial C# port
cpp: Partial C++ port
**iphone: iPhone client + port to Objective C / C++ (QR code only)**
jruby: Ruby wrapper
actionscript: partial port to Actionscript