0.0.8 • Published 5 years ago

rqrr-wasm v0.0.8

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

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

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago