Giter Site home page Giter Site logo

jl102 / koder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maslick/koder

0.0 0.0 0.0 3.82 MB

QR/bar code scanner for the Browser

Home Page: https://koder-prod.web.app

License: MIT License

JavaScript 70.84% C++ 9.45% CSS 4.04% Makefile 1.51% HTML 10.93% Dockerfile 3.22%

koder's Introduction

๐Ÿš€ NEW: Check Out Kameroon - QR/Bar Code Scanner as a Service ๐Ÿš€

=koder=

QR/bar code scanner for the Browser

npm Build Status License: MIT

๐Ÿ’ก Demo

https://koder-prod.web.app

๐Ÿš€ Features

  • QR/barcode module implemented in WebAssembly
  • Barcode support (ISBN, UPC-A, UPC-E, EAN-8, EAN-13, I25, ITF-14, CODE-128, CODE-39, CODE-93, CODABAR, DATABAR)
  • Uses Zbar C++ library (version 0.23.90)
  • Packaged as PWA (caching files with Service Worker, Add to Home Screen)
  • Mobile first (can be used on a Laptop as well)
  • Multiplatform (iOS, Android, Desktop)
  • QR/bar code recognition logic is performed off the browser's Main thread (i.e. Web Worker)
  • koder React component supports a jsqr based Web Worker (see jsQrWorker.js)
  • Emscripten-zbar-sdk Docker image based on emscripten/emsdk, Dockerfile
  • ReactJS component
  • Vanilla JS example
  • ๐Ÿ†• Turn on/off the beep sound
  • ๐Ÿ†• Support for UPN QR (Slovenia only)
  • ๐Ÿ†• EU Digital Covid Certificate validator (vaccination, test), works in offline mode!
  • ๐Ÿ†• Emscripten v3.1.1
  • ๐Ÿ†• npm package

โšก Usage

Install dependencies

npm install --global yarn
yarn install --frozen-lockfile

Run React app

npm run start
open https://locahost:8080

Productionize

npm run build                # -> build React app into ./public
npm run prod                 # -> serve static web app on port 8082
open http://localhost:8082

โšก NPM module

npm install @maslick/koder
// CommonJS
const Koder = require('@maslick/koder');

// ES6 modules
import Koder from '@maslick/koder';
const Koder = require('@maslick/koder');
const {loadImage, createCanvas} = require("canvas");

const getImageData = async (src) => {
  const img = await loadImage(src);
  const canvas = createCanvas(img.width, img.height);
  const ctx = canvas.getContext('2d');
  ctx.drawImage(img, 0, 0);
  return {
    data: ctx.getImageData(0, 0, img.width, img.height).data,
    width: img.width,
    height: img.height
  };
};

(async () => {
  const url = 'https://raw.githubusercontent.com/maslick/koder/master/screenshots/app_1.png';
  const koder = await new Koder().initialized;
  const {data, width, height} = await getImageData(url);

  const t0 = new Date().getTime();
  const res = koder.decode(data, width, height);
  const t1 = new Date().getTime();

  console.log(`Scanned in ${t1-t0} ms`);  // Scanned in 7 ms
  console.log(res);                       // http://en.m.wikipedia.org
})();

โ™ ๏ธ Development

Fetch or build the Builder image

docker pull maslick/emscripten-zbar-sdk
docker build -t maslick/emscripten-zbar-sdk -f docker/Dockerfile docker

Build WASM artifacts

# Linux, Mac Intel
docker run \
  -e INPUT_FILE=zbar/qr.cpp \
  -e OUTPUT_FILE=zbar \
  -e OUTPUT_DIR=public/wasm \
  -v $(pwd):/app \
  maslick/emscripten-zbar-sdk make -B
  
# Mac M1/M2
docker run \
  --platform linux/amd64 \
  -e INPUT_FILE=zbar/qr.cpp \
  -e OUTPUT_FILE=zbar \
  -e OUTPUT_DIR=public/wasm \
  -v $(pwd):/app \
  maslick/emscripten-zbar-sdk make -B

Clean the build artifacts (if necessary):

OUTPUT_DIR=public/wasm OUTPUT_FILE=zbar make clean

๐Ÿ”ญ References

koder's People

Contributors

maslick avatar dependabot[bot] avatar zigastegu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.