Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

How to use BarcodeDetectorZXing? #1

Open
marvinhinz opened this issue May 30, 2021 · 5 comments
Open

How to use BarcodeDetectorZXing? #1

marvinhinz opened this issue May 30, 2021 · 5 comments

Comments

@marvinhinz
Copy link

Hey,

this lib seems great to use the modern barcode detection api. For me qrcode and code_128 is really interesting.
In the readme it states, BarcodeDetectorZXing is not exposed at the moment. I tried building and using it locally but it fails with lots of errors. Is there any way to use the ZXing Detector Polyfill yet?

Thanks!

@gruhn
Copy link
Owner

gruhn commented May 31, 2021

BarcodeDetectorJsqr is still exposed because I haven't managed to run the ZXing implementation in a Web worker yet, so I presume it's not feasible for high frequency scanning. Like a camera stream. Building should work though. Can you show me the error messages?

@marvinhinz
Copy link
Author

Nevermind, i tried building it inside webpack encore that didnt work. Now i cloned your repo, modified the BarcodeDetector.ts to use the ZXing version and used microbundle to build it. Then it worked like a charm.
I am using it for live decoding of a camera stream. It uses a lot of cpu but it already works pretty good 👍🏼 Do you think with a webworker the performance would increase even more?

@gruhn
Copy link
Owner

gruhn commented May 31, 2021

Maybe… but the main reason is, if we don’t use a web worker, the expensive scanning operations run on the UI thread. So if that becomes too much, especially on low end devices, the UI could become less responsive. Animations have lower frame rate, clicks and other events are processed with perceivable lag, … stuff like this.

@muster-mark
Copy link

Hi,

I am trying to build this with BarcodeDetectorZXing. I cannot build it even before making modifications though. It fails with the following error:

(rpt2 plugin) Error: /Users/mark/Desktop/barcode-detector-polyfill/src/BarcodeDetectorJsqr.ts(6,30): semantic error TS2307: Cannot find module './worker/inline-worker' or its corresponding type declarations.

@gruhn
Copy link
Owner

gruhn commented Jul 26, 2021

It's a bit awkward at the moment. You have to build the web worker as separate file first. With a separate command:

./src/worker/build.sh && npm run build

However for BarcodeDetectorZXing that shouldn't be necessary because it doesn't use a worker.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants