All Projects → cozmo → Jsqr

cozmo / Jsqr

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

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Jsqr

quagga2-reader-qr
Quagga2 sample external reader for QR codes
Stars: ✭ 20 (-99.27%)
Mutual labels:  qrcode, qr-code, qr, qrcode-reader
qr-pirate
crawl QR-codes from search engines and look for bitcoin private keys
Stars: ✭ 58 (-97.87%)
Mutual labels:  qrcode, qr-code, qrcode-reader
paper-store
Cold store small files on paper as QR codes -- PGP keys, Bitcoin keys, Tox keys or any other small files in general.
Stars: ✭ 28 (-98.97%)
Mutual labels:  qrcode, qr-code, qr
Awesome Qr.js
An awesome QR code generator written in JavaScript.
Stars: ✭ 1,247 (-54.19%)
Mutual labels:  qr-code, qr, qrcode
Qr Ascii
A small library to generate QR codes with ascii
Stars: ✭ 63 (-97.69%)
Mutual labels:  qr-code, qr, qrcode
vk-qr
VK QR Code generator library
Stars: ✭ 43 (-98.42%)
Mutual labels:  qrcode, qr-code, qr
Qrbtf
An art QR code (qrcode) beautifier. 艺术二维码生成器。https://qrbtf.com
Stars: ✭ 1,391 (-48.9%)
Mutual labels:  qr-code, qr, qrcode
Qr Code
Web Component for generating QR codes
Stars: ✭ 425 (-84.39%)
Mutual labels:  qr-code, qr, qrcode
React Qr Svg
React component for rendering SVG QR codes
Stars: ✭ 134 (-95.08%)
Mutual labels:  qr-code, qr, qrcode
nova-qrcode-field
A Laravel Nova field to generate QR Code
Stars: ✭ 28 (-98.97%)
Mutual labels:  qrcode, qr-code, qr
qrcode
A flutter plugin for scanning QR codes. Use AVCaptureSession in iOS and zxing in Android.
Stars: ✭ 69 (-97.47%)
Mutual labels:  qrcode, qr-code, qr
Qr Code Scanner
📠 A simple, fast and useful progressive web application
Stars: ✭ 982 (-63.92%)
Mutual labels:  qr-code, qr, qrcode
Bardecoder
Detect and decode QR Codes, written in 100% Rust.
Stars: ✭ 145 (-94.67%)
Mutual labels:  qr-code, qrcode
Qrious
Pure JavaScript library for QR code generation using canvas
Stars: ✭ 1,160 (-57.38%)
Mutual labels:  qr, qrcode
Segno
Python QR Code and Micro QR Code encoder
Stars: ✭ 144 (-94.71%)
Mutual labels:  qr-code, qrcode
Zxinglite
🔥 ZXing的精简版,优化扫码和生成二维码/条形码,内置闪光灯等功能。扫描风格支持:微信的线条样式,支付宝的网格样式。几句代码轻松拥有扫码功能 ,ZXingLite让集成更简单。(扫码识别速度快如微信)
Stars: ✭ 2,117 (-22.23%)
Mutual labels:  qr-code, qrcode
Vue Qrcode Reader
A set of Vue.js components for detecting and decoding QR codes.
Stars: ✭ 1,240 (-54.45%)
Mutual labels:  qr-code, qrcode
Qrcode Library
Create QrCodes with ease
Stars: ✭ 184 (-93.24%)
Mutual labels:  qr, qrcode
Qrcode
💮 amazing QRCode generator in Python (supporting animated gif) - Python amazing 二维码生成器(支持 gif 动态图片二维码)
Stars: ✭ 8,613 (+216.42%)
Mutual labels:  qrcode, qr-code
Qr Code With Logo
带头像(logo)的二维码(qrcode)生成工具,无jQuery依赖,自由调整大小
Stars: ✭ 104 (-96.18%)
Mutual labels:  qr-code, qrcode

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].