npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

web-qr

v0.0.9

Published

This library improves on the ZXing library by shortcircuiting the localization phase by means of circular markers (surrounding the QR Code), and enhancing the candidate regions (contents of the circular markers) by means of hybrid classical/example-based

Downloads

5

Readme

Web-QR

This library improves on the ZXing library by shortcircuiting the localization phase by means of circular markers (surrounding the QR Code), and enhancing the candidate regions (contents of the circular markers) by means of hybrid classical/example-based self-superimposition. The primary goal is to increase the mean detection range.

Assuming the spot size on a detector of the QR code's constituent blocks is not less than the Abbe limit (λ/2, so about 250 nm for green light), or significantly smaller than the pixel size of the detector (typically on the order of 1-2 microns), increasing the resolution of the detector will increase the mean detection range (assuming noise remains within an acceptable limit), as will computational resolution enhancement.

We could naively enhance the entire image before passing it to ZXing, however this would incur a double performance penalty - the time taken to enhance the image (non-trivial), and an n^2 scaling of ZXing's execution time (a 4-fold resolution increase in both axes would correspond to a 16-fold increase).

To reduce the burden of resolution enhancement, we can couple our target codes with guide markers in the form of circles (akin to Australian or European speed signs), and look for those first. This can be easily parallelized, provided the ellipse detection algorithm used is tolerant to occlusion (or by using a second set of grid-squares to account for the regions split by the first set).

Installation

npm install web-qr

or,

yarn add web-qr

Usage

Source the build.js file like so:

<script src="/path/to/build.js"></script>

Importantly, due to the way emscripten fetches WebAssembly files, the .wasm files for both ZXing and webYaed (installed as dependencies by web-qr) need to be in the same folder as the page that requires them - if your page is at /test/, your zxing.wasm and web-yaed.wasm files need to be at /test/zxing.wasm and /test/web-yaed.wasm, respectively.

The best way to handle this is to make a symlink for each of them.

After you've set up the above, you can instantiate the module like so:

webQR().then((module) => {
    Object.assign(window, module);
    // or, manually assign each of the components:
    // window.webQR = module.webQR;
    // window.ZXing = module.ZXing;
    // window.webYaed = module.webYaed;
    // webQR.detect(CanvasContext2D: ctx)
})

The above copies the ZXing, webYaed and webQR objects onto the window object. Note that all of the above, WebAssembly, promises, Object static methods are relatively new features - support currently (May 11, 2017) hovers at ~52% globally (42% in Australia), so it is advised to do feature detection, and opt for either omitting the feature entirely (performance for the ellipse detection phase is not remotely acceptable in JS) or polyfilling with jsqrcode (note that this does not provide the localization improvement afforded by looking for guide ellipse markers). The relevant objects for feature detection are:

  • window.WebAssembly (polyfills for this are extremely slow)
  • window.Promise (this can be polyfilled in a performant manner)
  • Object.assign (trivial to polyfill, not central to operating the library)