zxing-js / library

Multi-format 1D/2D barcode image processing library, usable in JavaScript ecosystem.

Home Page:https://zxing-js.github.io/library/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scanning Area (Crop) / Perfomance

gyto23 opened this issue · comments

First of all, I want to say, great library!

I have implemented a simple barcode scanner on my app and I was planning to enhance it with specific items in it. I want to scan a specific barcode on the screen using video stream, however, its got into a problem when I have more than 3-4 barcodes on the same screen, and sometimes library picks the wrong one or doesnt even read it. I know it was already asked before in #39. However, for me it doesnt make no sense how to make a crop window that will scan only specific area.

I have recreated an example that was give but it only picks 1 code out of 20 when I am scanning it. https://stackblitz-starters-16tvvs.stackblitz.io

On the other hand, strich compare even other libraries and it looks common that it not always scanning properly.

Is there a way to have library always scan a barcode (20 out of 20 with faster performance) and what is best solution to have small area to scan (without overcomplicated scenario)? Also, have any one tried before to make a some sort of window that sticks to barcodes as canvas rectangle so at least we can see where camera is pointing when scanning.

Thanks

I simply use canvas to crop the image before sending it to ZXing.js: https://github.com/xulihang/barcode-detector-polyfill/blob/main/example/src/scripts/index.js#L240