zxing-js/library

Unable to scan image with large black backgrounds

ioripalm opened this issue · 1 comments

I replaced the image src in the example(barcode-image/index.html) to test whether the barcode can be scanned from the my high-definition camera.
微信图片_20240330112045
The resolution of the photo by my high-definition camera is 3264*2448.
1
In Picture 1, you can see that the barcode area only occupies a small area in the middle of the photo.This depends on the size of the shooting paper. Sometimes it is A4, sometimes it is A5, and sometimes it is just a small tip.After testing, it always fails.
If I crop out the black background of the original photo, it's work well.
2
Next I tried replacing the black background with white. Miraculously, it worked.
For pictures with a black background, is the black background recognized as part of the barcode?
3
I try to use this to crop the image and then scan the barcode is worked. Is there a way to directly identify the barcode?

I found a nice example base : ZXing WASM
The only drawback is that it is not very accurate in recognizing barcodes in non-horizontal conditions, which quaggaJS does very well.