Skip to content

seibii/shaken-qr-reader

Repository files navigation

shaken-qr-reader

npm version Libraries.io dependency status for GitHub repo npm bundle size npm GitHub

shaken-qr-reader is a library to read/parse Japanese 車検証 QR code

Installation

NPM

npm install shaken-qr-reader --save
yarn add shaken-qr-reader

Browser

You can find the script URL from https://www.jsdelivr.com/package/npm/shaken-qr-reader

Usage

const images = ... // common ImageData type objects. You can get from cameras or uploaded files etc...
const reader = new ShakenQRReader(); 
// const reader = new ShakenQRReader('kei'); for 軽自動車 has 6 QR codes
// const reader = new ShakenQRReader('kei_old'); for 軽自動車 has 3 QR codes

images.forEach((image) => {
    try {
        reader.push(image);
    } catch (error) {
        if (error instanceof InvalidQRCode) {
            console.log("The image is not valid shaken QR code.");
        } else if (error instanceof ReadQRCocde) {
            console.log("The image is already read.");
        }
    }
});

console.log(reader.isCompleted); // Whether all the QR codes are read or not
console.log(reader.missingIndex); // Indexs for the QR code which is not read
console.log(reader.result);

see example directory for real usage.

Development

Install dependencies

yarn

Run tests

yarn test

Run lint

yarn lint

License

see LICENSE