Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qrcode-opencv-wechat

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qrcode-opencv-wechat

[![NPM version](https://img.shields.io/npm/v/qrcode-opencv-wechat?color=a1b858&label=)](https://www.npmjs.com/package/qrcode-opencv-wechat)

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.2K
increased by0.58%
Maintainers
1
Weekly downloads
 
Created
Source

qrcode-opencv-wechat

NPM version

QR Code scanner in JavaScript, based on a WebAssembly build of OpenCV with Open CV 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.

Usage

npm i qrcode-opencv-wechat
import { scan } from 'qrcode-opencv-wechat'

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

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

You can also preload them with:

import { ready, scan } from 'qrcode-opencv-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

<video id="video">
import { scan } from 'qrcode-opencv-wechat'

const stream = await navigator.mediaDevices.getUserMedia({
  audio: false,
  video: {
    width: 512,
    height: 512,
  },
})

const video = document.getElementById('video')
video.srcObject = stream
video.play()

async function scanFrame() {
  const canvas = document.createElement('canvas')
  canvas.width = video.value.videoWidth
  canvas.height = video.value.videoHeight
  const ctx = canvas.getContext('2d')
  ctx.drawImage(videoEl.value!, 0, 0, canvas.width, canvas.height)
  const result = await scan(canvas)

  if (result?.text)
    alert(result?.text)
}

setInterval(scanFrame, 100) // scan one frame every 100ms

Sponsors

License

MIT License © 2023 Anthony Fu

FAQs

Package last updated on 25 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc