JavaScript条形码生成和扫码识别(Barcode scan)开源库

来源:互联网 发布:oracle导出数据库命令 编辑:程序博客网 时间:2024/05/07 04:01

条码具有易操作、易维护的特点。对于室外场合,使用计算机登记信息非常不方便,通过使用条码采集器,可以在操作现场将采集的条码信息保存在采集器中,然后传输到计算机。条码采集器外形轻便,操作简便,不需要安装配置软件系统,极大地提高了系统的使用性。

这里介绍分别甚至JavaScript实现的条形码相关开源库。

JsBarcode

JsBarcode 是一个生成条形码的开源库支持的有: CODE128 CODE128 (自动模式切换) CODE128 A/B/C (强制模式)等,在现代流量器上它会生成一个SVG矢量图用来生成条形码,使用如下:

var JsBarcode = require('jsbarcode');var Canvas = require("canvas");var canvas = new Canvas();JsBarcode(canvas, "Hello");// Do what you want with the canvas// See https://github.com/Automattic/node-canvas for more information

项目主页:  https://github.com/lindell/JsBarcode

quaggaJS

quaggaJS是由H5实现的javascript扫码库,能将条形码扫描成文字,支持静态图片和视频流的扫描。使用方法如下:

Quagga.init({    inputStream : {      name : "Live",      type : "LiveStream",      target: document.querySelector('#yourElement')    // Or '#yourElement' (optional)    },    decoder : {      readers : ["code_128_reader"]    }  }, function(err) {      if (err) {          console.log(err);          return      }      console.log("Initialization finished. Ready to start");      Quagga.start();  });

项目主页  https://github.com/serratus/quaggaJS

demo:https://serratus.github.io/quaggaJS/examples/static_images.html

0
 

阅读全文
0 0
原创粉丝点击