georapbox / barcode-scanner

A Progressive Web Application (PWA) that scans barcodes of various formats, using the Barcode Detection API.
https://georapbox.github.io/barcode-scanner/
MIT License
83 stars 37 forks source link

Feature Request: multi-barcodes scan #24

Open pigwa88 opened 2 days ago

pigwa88 commented 2 days ago

Hi, First of all, huge congratulations for creating a really cool app and some pretty solid code. However, could you add the ability to scan all barcodes using the camera?

For example, if I point the camera at a product that has, say, 5 different types of barcodes, could your app scan all 5 codes? Even better if there could be an option to choose which type of barcode should be scanned from these 5, for instance, only CODE128.

Alternatively, if you could outline the steps to modify the code in order to achieve this, I could do it myself, but you'll need to help me identify the main functions responsible for this that need modification. In theory, it shouldn't be too difficult, but my strong suit is PHP, and while I handle JS well, it's not perfect.

Best regards.

georapbox commented 1 day ago

Hi, Thanks for the kind words!

Both feature requests sound reasonable enough. Especially the second one, about giving the ability to customize the formats to detect is something I've been thinking of adding lately.

Regarding scanning multiple barcodes, this is something that is definitely supported by the BarcodeDetector API but it was a deliberate decision I had taken from the beginning to only support for one result for simplicity reasons and because it was covering my needs. In general I think it's doable to support it although it will require some refactor because it will affect the codebase on a few places, eg where I display the scanned results along with actions to copy and share, etc. In addition there are a few other concerns, eg if the polyfill I use for non supported browsers does support multiple scans, how well the camera can capture multiple barcodes, etc.

So, having said all that, I will definitely start investigating for both feature requests, probably starting from the second one about supported formats selection which seems to be more straightforward.