Coder Social home page Coder Social logo

myisaak / zbar-wasi Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 4.0 209 KB

Webassembly (WASI) port of Zbar barcode scanner

Home Page: https://myisaak.github.io/zbar-wasi

Makefile 9.73% HTML 20.85% Shell 1.21% JavaScript 33.93% Dockerfile 8.65% C 25.64%
scanning-barcodes zbar-wasi zbar scan barcodes wasm webassembly

zbar-wasi's Introduction

zbar-wasi

Node.js CI Code scanning - action npm (tag) Maintenance License: MIT Downloads Total Downloads Month

Scan barcodes in web browsers

This library allows web browsers to scan barcodes with a Webassembly and WASI backend.

Why?

  • Unlike most Webassembly projects this one is compiled with WASI instead of Emscripten.
  • Optimized for size with a WASM binary size of 161.98 KB gzipped (244.40 KB uncompressed).
  • Works perfectly on mobile devices and desktop

Demo

Try scanning barcodes with your camera: https://myisaak.github.io/zbar-wasi/ Watch your command line for found barcodes.

Installation

npm install zbar-wasi

Usage

import { scanImage, createZbar } from "zbar-wasi";

const start = async () => {
  // move ./node_modules/zbar-wasi/dist/zbar.wasm to your web directory"
  const ZBAR = await createZbar({ wasmpath: "./zbar.wasm" });
  const imageData = ctx.getImageData(0, 0, width, height);
  const results = scanImage(imageData);
  console.log(results);
  // outputs [ barcode1, barcode2, ... ]
}
start();

zbar-wasi's People

Contributors

myisaak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

zbar-wasi's Issues

Problem on old versions of chrome

Hi Isaak

First of all thank you for the great work.

I'm facing a problem with old versions of chrome and webkit based browsers on android (chrome, edge etc.).

The exception i'm getting is

Uncaught TypeError: wasm function signature contains illegal type
    at /wasm-function[11]:28
    at /wasm-function[63]:34
    at /wasm-function[62]:7
    at scanImage (zbar-wasi.esm.js:5186)
    at renderLoop ((index):25)
    at track ((index):70)
    at HTMLVideoElement.domVideo.addEventListener ((index):62)

I was able to reproduce it by using an old version of chromium for windows 72.0.3579.0, which can be downloaded here:

https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/599392/

I have reasons to believe that this exception is also causing #2 , since in the past I noticed a certain coherence between the behaviours of this version of chrome and iOS Safari.

This is as far as I can reach with my limited knwledge of wasm.

Could you please look into it?

Thank you again

Daniele

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.