gomi42 / FocalMaster

Scan, create HP 41 barcodes
GNU Affero General Public License v3.0
0 stars 1 forks source link

Checksum error in [...]\bct1.jpg #7

Open m-stgt opened 1 year ago

m-stgt commented 1 year ago

Saw by chance you published an update of your "Focal"Master (while the title page of Manual.pdf still shows Version 1.0). The description of the barcode finding algorithm is quite impressive, so I testet it with following screen shot -- bct1 To my surprise, scanning it returned error message "Checksum error in C:\Users\jg\Downloads\bct1.jpg"

A second test with an enlarged detail of same screen shot -- bct2 resulted in "No barcodes found in C:\Users\jg\Downloads\bct2.jpg" -- what astonished me even more, since my very first try works w/o problem, see here.

Best, M.

gomi42 commented 1 year ago

Hello M.

thx for your description. After reading it I was astonished as well. Because I didn't change the logic of the scanner. The good news is the scanner still scans your first version (it is part of my test suite since then).

The analysis shows:

1: Your current barcodes are a bit smaller than the first version. The first row of the new version is only about 30 pixel smaller. The scanner wasn't prepared for such small barcodes. That's an easy fix, the scanner simply needs to start with a smaller box size. The drawback is it takes longer to scan standard sized barcodes. Its noticable but not a real problem.

2: Small, detailed, sharp edges are some kind of contradiction with jpg compression. The following shows a part of your 100% image:

big3

One of the first steps of the scanner is to convert the original image into a pure black and white image (no grays). For that the decision needs to be made for each pixel depending on its gray value. The marked yellow and green bars are the problem. There are sharp edges, both bars result in a 2 pixel wide black bar. So far so good.

At the end a row consists of bars with three different widths: 1 px, 2 px and 3 px. The 1 px bars are clearly a logical "0", the 3 px bars a "1". The scanner now needs to decide what the 2 px bars mean. It can only mean "0" or "1" but not both. But the last is exactly the case here. Sometimes it means "0", sometimes "1".

The following image shows what the scanner "sees", the pur black and white bars. The first row shows the first bars of your very first barcode. Yellow and green mark the same bars as in the image above. The yellow bar is a "1", the green a "0". Because here only 3 px wide bars mean a "1".

The second row shows the beginning of your new barcode. As you see the yellow bar is 2 px wide and the green bar as well. That means the scanner has no chance :-(

results

In short the new barcode isn't necessarily too small, the jpg compression in conjunction with its small size makes it unreadable.

Of course I tried different setting for the black/white conversion. Nothing really helped. If some setting helped normal barcodes didn't work anymore.

Michael

m-stgt commented 1 year ago

Had to bugfix my Software Defined Wand -- this post might be a hint for your problem.