Zurück zum Ranking

cozmo/jsQR

TypeScriptcozmo.github.io/jsQR/

A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.

qrcodeqr-parsing-librarytypescriptqrqrcode-readerqr-codeqr-scanner
Sterne-Wachstum
Sterne
4k
Forks
615
Wochenwachstum
Issues
79
2k4k
Dez. 2015Juni 2019Jan. 2023Juli 2026
Artefaktenpmnpm install jsqr
README

jsQR

Build Status

A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.

Demo

Installation

NPM

Available on npm. Can be used in a Node.js program or with a module bundler such as Webpack or Browserify.

npm install jsqr --save
// ES6 import
import jsQR from "jsqr";

// CommonJS require
const jsQR = require("jsqr");

jsQR(...);

Browser

Alternatively for frontend use jsQR.js can be included with a script tag

<script src="jsQR.js"></script>
<script>
  jsQR(...);
</script>

A note on webcams

jsQR is designed to be a completely standalone library for scanning QR codes. By design it does not include any platform specific code. This allows it to just as easily scan a frontend webcam stream, a user uploaded image, or be used as part of a backend Node.js process.

If you want to use jsQR to scan a webcam stream you'll need to extract the ImageData from the video stream. This can then be passed to jsQR. The jsQR demo contains a barebones implementation of webcam scanning that can be used as a starting point and customized for your needs. For more advanced questions you can refer to the getUserMedia docs or the fairly comprehensive webRTC sample code, both of which are great resources for consuming a webcam stream.

Usage

jsQR exports a method that takes in 3 arguments representing the image data you wish to decode. Additionally can take an options object to further configure scanning behavior.

const code = jsQR(imageData, width, height, options?);

if (code) {
  console.log("Found QR code", code);
}

Arguments

  • imageData - An Uint8ClampedArray of RGBA pixel values in the form [r0, g0, b0, a0, r1, g1, b1, a1, ...]. As such the length of this array should be 4 * width * height. This data is in the same form as the ImageData interface, and it's also commonly returned by node modules for reading images.
  • width - The width of the image you wish to decode.
  • height - The height of the image you wish to decode.
  • options (optional) - Additional options.
    • inversionAttempts - (attemptBoth (default), dontInvert, onlyInvert, or invertFirst) - Should jsQR attempt to invert the image to find QR codes with white modules on black backgrounds instead of the black modules on white background. This option defaults to attemptBoth for backwards compatibility but causes a ~50% performance hit, and will probably be default to dontInvert in future versions.

Return value

If a QR is able to be decoded the library will return an object with the following keys.

  • binaryData - Uint8ClampedArray - The raw bytes of the QR code.
  • data - The string version of the QR code data.
  • chunks - The QR chunks.
  • version - The QR version.
  • location - An object with keys describing key points of the QR code. Each key is a point of the form {x: number, y: number}. Has points for the following locations.
    • Corners - topRightCorner/topLeftCorner/bottomRightCorner/bottomLeftCorner;
    • Finder patterns - topRightFinderPattern/topLeftFinderPattern/bottomLeftFinderPattern
    • May also have a point for the bottomRightAlignmentPattern assuming one exists and can be located.

Because the library is written in typescript you can also view the type definitions to understand the API.

Contributing

jsQR is written using typescript. You can view the development source in the src directory.

Tests can be run with

npm test

Besides unit tests the test suite contains several hundred images that can be found in the /tests/end-to-end/ folder.

Not all the images can be read. In general changes should hope to increase the number of images that read. However due to the nature of computer vision some changes may cause images that pass to start to fail and visa versa. To update the expected outcomes run npm run-script generate-test-data. These outcomes can be evaluated in the context of a PR to determine if a change improves or harms the overall ability of the library to read QR codes. A summary of which are passing and failing can be found at /tests/end-to-end/report.json

After testing any changes, you can compile the production version by running

npm run-script build

Pull requests are welcome! Please create seperate branches for seperate features/patches.

Ähnliche Repositories
Tamsiree/RxTool

Android开发人员不得不收集的工具类集合 | 支付宝支付 | 微信支付(统一下单) | 微信分享 | Zip4j压缩(支持分卷压缩与加密) | 一键集成UCrop选择圆形头像 | 一键集成二维码和条形码的扫描与生成 | 常用Dialog | WebView的封装可播放视频 | 仿斗鱼滑动验证码 | Toast封装 | 震动 | GPS | Location定位 | 图片缩放 | Exif 图片添加地理位置信息(经纬度) | 蛛网等级 | 颜色选择器 | ArcGis | VTPK | 编译运行一下说不定会找到惊喜

KotlinApache License 2.0dialogprogressbar
12.3k2.8k
x-hw/amazing-qr

💮 amazing QRCode generator in Python (supporting animated gif) - Python amazing 二维码生成器(支持 gif 动态图片二维码)

PythonPyPIGNU General Public License v3.0qrcodegif
10.8k1.6k
claudiodangelis/qrcp

:zap: Transfer files over wifi from your computer to your mobile device by scanning a QR code without leaving the terminal.

GoGo ModulesMIT Licenseutilitygolang
qrcp.sh
10.5k546
mrousavy/react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.

TypeScriptnpmMIT Licensereact-nativecamera
visioncamera.margelo.com
9.5k1.4k
bingoogolapple/BGAQRCode-Android

QRCode 扫描二维码、扫描条形码、相册获取图片后识别、生成带 Logo 二维码、支持微博微信 QQ 二维码扫描样式

Cqrcodeqrcode-scanner
8k1.8k
ggerganov/ggwave

Tiny data-over-sound library

C++MIT Licensedata-over-soundsound-library
youtu.be/Zcgf77T71QM
7.8k460
bndw/wifi-card

📶 Print a QR code for connecting to your WiFi (wificard.io)

JavaScriptnpmMIT Licensewifireact
wificard.io
7.2k498
latentcat/qrbtf

AI & parametric QR code generator. AI & 参数化二维码生成器。https://qrbtf.com

TypeScriptnpmGNU General Public License v3.0qrqrcode
qrbtf.com
7k589
mebjas/html5-qrcode

A cross platform HTML5 QR code reader. See end to end implementation at: https://scanapp.org

TypeScriptnpmApache License 2.0html5qrcode
qrcode.minhazav.dev
6.2k1.1k
zxlie/FeHelper

😍FeHelper--Web前端助手(Awesome!Chrome & Firefox & MS-Edge Extension, All in one Toolbox!)

JavaScriptnpmMIT Licensefehelperjson
fehelper.com
5.6k1.3k
Shane32/QRCoder

A pure C# Open Source QR Code implementation

C#MIT Licenseqrcodec-sharp
5.1k1.2k
endroid/qr-code

PHP QR Code library that helps you create QR codes in a jiffy

PHPPackagistMIT Licenseqrcodedata-uri
endroid.nl
4.8k770