Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Bug Fixes for Reading Barcodes from an Image - III

0.00/5 (No votes)
5 Jul 2012 2  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here