Click here to Skip to main content
Click here to Skip to main content

Bug Fixes for Reading Barcodes from an Image - III

, 5 Jul 2012
Rate this:
Please Sign up or sign in to vote.
Bug Fixes for Reading Barcodes from an Image - III

This post provides bug fixes for Reading Barcodes from an Image - III. The author was contacted, but did not have time to review the fixes, so both the author and CodeProject editors agreed this post was the best option.

In 2011 I started working on a contract management project. The relation between the contracts and some records in a database where done by using barcodes. In June 2012 we performed the last tests on the software. During the test, an attentive member of the test team noticed that the barcode for the ID 100328 was not readable. I checked the issue and found out that the reason was due to our barcode reader module. Due to the time constraint to look for a complete new solution I decided to debug the barcode reader software, which is based on the nice Reading Barcodes from an Image - III article. With the help of wikipedia and the smashing page Le code 128 I learned about the theory of Code128. I created a small test environment, based on open source software iTextSharp, to produce a huge amount of testscans in a loop. Within the test environment I found out that the original software has several major bugs. The bugs cause about 0.5% of the scans not recognizable by the original software.

Here are the bugs in details and how I have fixed them:

  1. Checksum can be longer than two characters

    Each Code128 barcode consists of several patterns which always have the following schema: Start - Data - Checksum - Stop

    The original code uses only two characters to save the checksum and didn't take into account that it can be longer, e.g. 102. I have fixed that by using a stringlist instead of a string.

  2. Confusion of checksum and change of codepage

    In Code128 it is possible to change the codepage. This is done by using a special pattern. In rare cases it is possible that the checksum at the end of the data-part of the code is a special pattern. In original code this causes an error because the checksum is lost. I fixed that by saving the special pattern until it is clear on whether it is the end of the barcode or a code page change.

  3. Not less than 4 narrow black bars in barcode

    The original code make an assumption that it is not possible to have less than 4 black bars in the barcode. I found out that this assumption is incorrect. It is possible to have only two black bars in the barcode, e.g. in the Code128 representation of the number 30.

  4. Usage of pipe symbols to separate scan results

    The original code use pipe symbols | to separate the results if there are more than one barcode on a page. This causes errors when using such symbol in the barcode. Again, I fixed that by using a stringlist instead of a string.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Matthias Böhnke
Software Developer Masters of Arts Anwendungsentwicklung GmbH
Germany Germany
No Biography provided

Comments and Discussions

 
SuggestionTwo corrections Pinmembermatiascabanillas4-Oct-12 9:36 
QuestionHow to use this code? Pinmembervv_ekb21-Sep-12 7:53 
QuestionSmall test environment PinmemberMember 69975798-Sep-12 3:37 
GeneralThanks! PinmemberFurryPlatypus6-Jul-12 9:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 5 Jul 2012
Article Copyright 2012 by Matthias Böhnke
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid