Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
Q

qr-scanner-wechat

> 编程语言
Open source

QR Code scanner in JS with Open CV and WeChat's Algorithm

400 stars0 likes4 views
WebsiteGitHub

About

QR Code scanner in JS with Open CV and WeChat's Algorithm

qr-scanner-wechat

QR Code scanner for JavaScript, based on a WebAssembly build of OpenCV and WeChat QR Code Scanner. Provides a much better detection rate and error tolerance.

Ported and rewritten from leidenglai/opencv-js-qrcode for modern browser build and easier usage. Huge thanks to @leidenglai for the previous work and research.

  • ️ Basic playground demo
  • ️ Anthony's QR Toolkit

Usage

bash
npm i qr-scanner-wechat
typescript
import { scan } from 'qr-scanner-wechat'

const result = await scan(canvas) // Or ImageElement

Upon the first call of scan, around 2.5MB gzipped of WebAssembly and models will be loaded asynchronously.

You can also preload them with:

typescript
import { ready, scan } from 'qr-scanner-wechat'

await ready()
const result = await scan(canvas)

Stream

In case you want to scan with streams like camera inputs, here is some code snippet for reference

xml
…

Node.js

It's also possible to do scanning on Node.js. To do so, you'll need some additional transformations to an ImageData-compatible format. We recommend using sharp and here is an example:

typescript
import { scan } from 'qrcode-openev-wechat'
import sharp from 'sharp'

const image = sharp('/path/to/image.png') // or Buffer, anything sharp supports

const { data, info } = await image
// .resize(1000) // you can resize first to improve the performance
  .ensureAlpha()
  .raw()
  .toBuffer({
    resolveWithObject: true,
  })

const result = await scan({
  data: Uint8ClampedArray.from(data),
  width: info.width,
  height: info.height,
})

console.log(result?.text)

Sponsors

License

MIT License © 2023 Anthony Fu

Issues· 2 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言