dlbeer / quirc

QR decoder library
Other
882 stars 286 forks source link

Have quirc run in the browser by compiling to web assembly #76

Closed JaapHaitsma closed 4 years ago

JaapHaitsma commented 4 years ago

You need to install emscripten See: https://emscripten.org/docs/getting_started/downloads.html

After that run make quirc.js

Then serve the js directory in a webserver and open demo.html in your browser and you will see that your browser recognized the QR code

I made also PWA app that uses the the js library. Open it with your phone https://qrcode-quirc.glitch.me/ It also works offline and you can install it. The only I still need to do is show the detected QR code in a nice interface. If you click on the QR code icon it will copy it to the clipboard. If you are interested in the code of the app you can find it here https://glitch.com/edit/#!/qrcode-quirc?path=script.js%3A1%3A0

Nice thing is that because all the heavylifting is in the wasm engine that it runs quite smoothly even on an older mid range processor like a snapdragon 625

What I did in a nutshell to get quirc in the browser

dlbeer commented 4 years ago

On Mon, May 18, 2020 at 08:47:19PM -0700, JaapHaitsma wrote:

You need to install emscripten See: https://emscripten.org/docs/getting_started/downloads.html

After that run make quirc.js

Then serve the js directory in a webserver and open demo.html in your browser and you will see that your browser recognized the QR code

I made also PWA app that uses the the js library. Open it with your phone https://qrcode-quirc.glitch.me/ It also works offline and you can install it. The only I still need to do is show the detected QR code in a nice interface. If you click on the QR code icon it will copy it to the clipboard. If you are interested in the code of the app you can find it here https://glitch.com/edit/#!/qrcode-quirc?path=script.js%3A1%3A0

Nice thing is that because all the heavylifting is in the wasm engine that it runs quite smoothly even on an older mid range processor like a snapdragon 625

What I did in a nutshell to get quirc in the browser

  • Add a cpp wrapper to quirc
  • Make a webidl file such that emscripten knows how to map cpp class to javascript
  • Build the wasm and corresponding js binding with emscripten
  • Write a wrapper QuircJS.js around this to make using the resulting library easier

This looks interesting and useful, but I'm not sure that I'd be able to maintain it as quirc changes.

Would it be feasible to start a separate project to maintain the bindings and build rules?

Cheers, Daniel

-- Daniel Beer dlbeer@gmail.com http://dlbeer.co.nz/ PGP: BA6E 0B26 1F89 246C E3F3 C910 1E58 C43A 160A 553B

JaapHaitsma commented 4 years ago

Hi Daniel,

I can help you maintain it in your repo. Maintenance should be very low. I just have a CPP wrapper around your public API. So only if you change the public API there would be a need to do changes in my code. However if you prefer I can make a QuircJS project that pulls in quirc as a submodule.

Let me know what you think is the best

Jaap

On Sun, May 24, 2020 at 10:06 PM Daniel Beer notifications@github.com wrote:

On Mon, May 18, 2020 at 08:47:19PM -0700, JaapHaitsma wrote:

You need to install emscripten See: https://emscripten.org/docs/getting_started/downloads.html

After that run make quirc.js

Then serve the js directory in a webserver and open demo.html in your browser and you will see that your browser recognized the QR code

I made also PWA app that uses the the js library. Open it with your phone https://qrcode-quirc.glitch.me/ It also works offline and you can install it. The only I still need to do is show the detected QR code in a nice interface. If you click on the QR code icon it will copy it to the clipboard. If you are interested in the code of the app you can find it here https://glitch.com/edit/#!/qrcode-quirc?path=script.js%3A1%3A0

Nice thing is that because all the heavylifting is in the wasm engine that it runs quite smoothly even on an older mid range processor like a snapdragon 625

What I did in a nutshell to get quirc in the browser

  • Add a cpp wrapper to quirc
  • Make a webidl file such that emscripten knows how to map cpp class to javascript
  • Build the wasm and corresponding js binding with emscripten
  • Write a wrapper QuircJS.js around this to make using the resulting library easier

This looks interesting and useful, but I'm not sure that I'd be able to maintain it as quirc changes.

Would it be feasible to start a separate project to maintain the bindings and build rules?

Cheers, Daniel

-- Daniel Beer dlbeer@gmail.com http://dlbeer.co.nz/ PGP: BA6E 0B26 1F89 246C E3F3 C910 1E58 C43A 160A 553B

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dlbeer/quirc/pull/76#issuecomment-633341443, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG5AT2HA235JLW32SSX42TRTHHC3ANCNFSM4NEUBMKQ .

dlbeer commented 4 years ago

On Mon, May 25, 2020 at 08:32:46AM -0700, JaapHaitsma wrote:

I can help you maintain it in your repo. Maintenance should be very low. I just have a CPP wrapper around your public API. So only if you change the public API there would be a need to do changes in my code. However if you prefer I can make a QuircJS project that pulls in quirc as a submodule.

Let me know what you think is the best

I think it's probably cleaner to maintain it as a separate repository pulling in a submodule -- then you'd be free to pull in whatever tooling you like. Currently, I'd prefer to keep the core library dependent on as few tools and libraries as possible as it needs to run on a wide variety of platforms.

Cheers, Daniel

-- Daniel Beer dlbeer@gmail.com http://dlbeer.co.nz/ PGP: BA6E 0B26 1F89 246C E3F3 C910 1E58 C43A 160A 553B

JaapHaitsma commented 4 years ago

Daniel,

I made a separate repo https://github.com/JaapHaitsma/QuircJS where I put quirc as submodule. So closing this merge request.

kaworu commented 4 years ago

Should we have a list of theses type of projects, i.e. "versions" of quirc, in the README?

dlbeer commented 4 years ago

On Tue, May 26, 2020 at 01:33:05AM -0700, Alexandre Perrin wrote:

Should we have a list of theses type of projects, i.e. "versions" of quirc, in the README?

That would probably be a good idea, if you're happy to compile the list!

-- Daniel Beer dlbeer@gmail.com http://dlbeer.co.nz/ PGP: BA6E 0B26 1F89 246C E3F3 C910 1E58 C43A 160A 553B