zxing-cpp / zxing-cpp

C++ port of ZXing
Apache License 2.0
1.22k stars 390 forks source link

Adding whitespace impacts detection of datamatrix code #276

Closed riedel closed 2 years ago

riedel commented 2 years ago

The following code fails for me reproducibly after adding 200 pixels, however not 100 pixels, for different codes like this one (I can probably produce a test case without an image if needed)

test

import sys
import zxingcpp
from PIL import Image

img = Image.open(sys.argv[1])
results = zxingcpp.read_barcodes(img)
assert(len(results) > 0)
img2 = Image.new(img.mode, (img.size[0], img.size[1]+100))
img2.paste(img)
results2 = zxingcpp.read_barcodes(img2)
assert(len(results2) > 0)
img2 = Image.new(img.mode, (img.size[0], img.size[1]+200))
img2.paste(img)
results3 = zxingcpp.read_barcodes(img2)
assert(len(results3) > 0)
axxel commented 2 years ago

This is a duplication of #189. If you can compile the library yourself, you can fix this easily. Please see https://github.com/nu-book/zxing-cpp/issues/189#issuecomment-761121357.

It seems I should find a way to enable that code "somehow". Every once in a while someone stumbles over this. The thing is, that every way to deal with this has its drawbacks and the current situation is simply "how it has always been", so sort of the default without a convincing alternative. :-/

riedel commented 2 years ago

Thanks, it would be really good if it was somehow documented, that tryharder is force-disabled.

IMHO, it would be good to make tryharder tri-state: null (depends on decoder), true, false , so that it works if explicitly set.

For me none of the big codes are detected on an A4 sheet, so I will happily pay the price...

Edit: I compiled it myself, so I will check (I needed to compile it to work under cygwin: might do a PR here as well if I have time and the decoder actually works with try-harder)

riedel commented 2 years ago

Did a quick check: works nicely without any performance degradation in my case

axxel commented 2 years ago

Thanks for the feedback. Your tri-state idea is interesting. I'll think about it. Good to hear that you could fix your issue.

Any PR to fix issues under cygwin is welcome.