Click here to Skip to main content
15,034,551 members
Articles / Desktop Programming / Win32
Posted 5 Jul 2012


27 bookmarked

Bug Fixes for Reading Barcodes from an Image - III

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
5 Jul 2012CPOL2 min read
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.


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


About the Author

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

Comments and Discussions

BugBug fix Pin
mrodby14-Jun-17 19:30
Membermrodby14-Jun-17 19:30 
QuestionHow can i get the barcode width and height? Pin
Varalakshmi Chandran4-May-15 23:54
MemberVaralakshmi Chandran4-May-15 23:54 
QuestionThanks a lot, can you help me with I2of5 Pattern? Pin
muktak5-Nov-14 21:45
Membermuktak5-Nov-14 21:45 
SuggestionTwo corrections Pin
matiascabanillas4-Oct-12 9:36
Membermatiascabanillas4-Oct-12 9:36 
QuestionHow to use this code? Pin
vv_ekb21-Sep-12 7:53
Membervv_ekb21-Sep-12 7:53 
QuestionSmall test environment Pin
Member 69975798-Sep-12 3:37
MemberMember 69975798-Sep-12 3:37 
GeneralThanks! Pin
CorvinusSoftware6-Jul-12 9:11
professionalCorvinusSoftware6-Jul-12 9:11 

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

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