rqrr-wasm

0.0.8 • Public • Published

rqrr-wasm

An npm module that use rqrr compiled to wasm to use easily in your webpack project.

Instructions

  1. Install the module with its peer dependencies
yarn add rqrr-wasm memory-fs fs-extra
  1. Add the webpack plugin to your webpack configuration
import RqrrWasmPlugin from 'rqrr-wasm/dist/webpack-plugins';
 
// webpack configuration file
webpackConfig = {
  plugins: [
    // other plugins
    new RqrrWasmPlugin(), // put this last
  ],
}
  1. Import the module in your code
import wasmModule from 'rqrr-wasm';
  1. Call init() to load the .wasm file, then you can decode a QR code by passing an Uint8Array of the image data
wasmModule.init().then(() => {
  const canvas = document.createElement('canvas');
  canvas.width = 300;
  canvas.height = 300;
 
  canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
  canvas.toBlob(blob => {
    const reader = new FileReader();
 
    reader.addEventListener('loadend', () => {
      const arrayBuffer = reader.result;
      const output = wasmModule.decode(new Uint8Array(arrayBuffer));
 
      console.log("DECODED QR: ", output); // the string output here!
    });
 
    reader.readAsArrayBuffer(blob);
  });
});

Example

An example of how to use this can be seen in this repo https://github.com/jackyef/rqrr-wasm

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.8
    1
    • latest

Version History

Package Sidebar

Install

npm i rqrr-wasm

Weekly Downloads

1

Version

0.0.8

License

MIT

Unpacked Size

2.46 MB

Total Files

25

Last publish

Collaborators

  • jackyef