rxing-core / rxing-wasm Goto Github PK
View Code? Open in Web Editor NEWWASM bindings for common rxing functions
Home Page: https://www.npmjs.com/package/rxing-wasm
License: Apache License 2.0
WASM bindings for common rxing functions
Home Page: https://www.npmjs.com/package/rxing-wasm
License: Apache License 2.0
looks great. tried to play with it and was going great. I do think you will need to eventually create a table that maps between properties and thier type ( and maybe even a column of an example value at the so it will be explicit) .
one last this is that with TryHarder true nad UpcEanExtension - I managed to make the browser totally freeze while trying to scan this particular image.
I will be more than happy if you could have a look why would that be .
Originally posted by @VerioN1 in #1 (comment)
Hi,
My knowledge of Rust and of WebAssembly internals is still pretty shallow so apologies in advance if I am missing something obvious. I am trying to use the rxing-wasm
package as bundled by the wasm-pack build
command described here:
https://www.furidamu.org/blog/2020/07/10/rust-webassembly-in-the-browser/
That seems to work fine and I am able to initialize the resultant WASM binary and invoke the convert_js_image_to_luma
function but when I try to call decode_barcode
it panics with the following error:
Uncaught RuntimeError: unreachable executed
decode_barcode http://localhost:8080/rxing_wasm.js:187
onload http://localhost:8080/?:43
onclick http://localhost:8080/?:30
main http://localhost:8080/?:24
async* http://localhost:8080/?:54
[rxing_wasm_bg.wasm:1171526:1](http://localhost:8080/rxing_wasm_bg.wasm)
__rust_start_panic http://localhost:8080/rxing_wasm_bg.wasm:1171526
rust_panic http://localhost:8080/rxing_wasm_bg.wasm:1157051
hc53aea0352e77326 http://localhost:8080/rxing_wasm_bg.wasm:1006605
ha183a8279614f03a http://localhost:8080/rxing_wasm_bg.wasm:1062504
hc33870f333461503 http://localhost:8080/rxing_wasm_bg.wasm:1154372
rust_begin_unwind http://localhost:8080/rxing_wasm_bg.wasm:1116658
hf4a9df75710ece83 http://localhost:8080/rxing_wasm_bg.wasm:1147033
h8c0b59521a475ac0 http://localhost:8080/rxing_wasm_bg.wasm:1085500
hac996b83e550b52f http://localhost:8080/rxing_wasm_bg.wasm:624364
he1247e4575455453 http://localhost:8080/rxing_wasm_bg.wasm:746459
hc2a7bc7f939092d4 http://localhost:8080/rxing_wasm_bg.wasm:882929
hf770383115561eeb http://localhost:8080/rxing_wasm_bg.wasm:947342
<rxing::qrcode::qr_code_reader::QRCodeReader as rxing::reader::Reader>::decode_with_hints::h004a4523f4768536 http://localhost:8080/rxing_wasm_bg.wasm:389867
I have been testing this with a PDF417 barcode image that can be successfully decoded using the rxing-cli
tool. All the code in question can be found here:
https://github.com/sfomuseum/rust-rxing-wasm/blob/main/www/index.html
The image I've been testing with is here:
https://github.com/sfomuseum/rust-rxing-wasm/blob/main/images/deltabp.png
Whic was taken from here:
https://krebsonsecurity.com/2015/10/whats-in-a-boarding-pass-barcode-a-lot/
Do you have any thoughts on what might be happening here or what I am doing wrong?
I have a project running with rxing-wasm on my mac and worked fine. But when I wanted to move to windows - running the same code that works on mac - gives me this error
this is the code I was trying to run:
const ctx = canvas.getContext('2d'); if (!ctx) { throw 'no context'; } const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); try { // @ts-ignore const luma_data = convert_js_image_to_luma(imageData.data); const hints = new DecodeHintDictionary(); hints.set_hint(DecodeHintTypes.PossibleFormats, 'UpcEanExtension'); hints.set_hint(DecodeHintTypes.TryHarder, 'true'); const result = decode_barcode_with_hints(luma_data, canvas.width, canvas.height, hints); console.warn(result.text()); } catch (e) { console.log(e); }
I noticed that you need to convert the image to an array of 8bit luma data, or rgb before passing it to decode_barcode. why not also expose the methods that do that?
Maybe I'm wrong and you can do this in vanilla js, but I couldn't find any example that do that without installing zxing (for js).
If there are other ways to pass image from js to the decoding function without installing zxing, I will be happy to know .
Hi,
My Rust-knowledge is a little better than the last time I asked a question but it is still pretty raw so apologies if I've missed something obvious.
I have (4) barcodes all created by, and which can be decoded by, rxing-cli
in the PDF-417, Aztec, DataMatrix and QR code formats. Copies of these barcodes can be found here:
https://github.com/sfomuseum/rs-rxing-wasm/tree/main/images
When I try to decode them using a rxing-wasm
binary created by wasm-pack build --target web
only the PDF-417 can be decoded. All the others fail with a "Not found" error. For example:
Uncaught not found [rxing_wasm.js:293:14](http://localhost:8080/rxing_wasm.js)
decode_barcode_with_hints http://localhost:8080/rxing_wasm.js:293
onload http://localhost:8080/:59
(Async: EventHandlerNonNull)
onclick http://localhost:8080/:44
(Async: EventHandlerNonNull)
main http://localhost:8080/:38
AsyncFunctionNext self-hosted:810
(Async: async)
<anonymous> http://localhost:8080/:79
The code in question can be found here:
https://github.com/sfomuseum/rs-rxing-wasm/blob/main/www/index.html
I have spent some time poking around the rxing-cli
package to see whether there are hints, or other arguments, I should be passing to the decode_barcode
function but it doesn't seem like it? I get the same results if I call decode_barcode
or decode_barcode_with_hints
. I feel like I must be missing something obvious but I am having trouble seeing what. Do you have any ideas?
Thanks,
@yuezk Should I move the rxing-wasm crate into the RXing org on npmjs? Thoughts?
Currently, a new, empty HashMap
is passed into the Rust library when encode_barcode
is called. However for Telepen Numeric, I would need to pass a hint.
Could there either be an additional method - e.g. encode_barcode_with_hints
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.