npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

qr-code-detector

v1.0.2

Published

QR code detection and decoding with base64 image extraction. Native Node.js addon using OpenCV.

Readme

QR Code Detector

Node.js native addon for detecting and decoding QR codes using OpenCV. This module runs QR code detection in separate worker threads to ensure non-blocking operation.

Features

  • Single QR Code Detection: Detect and decode a single QR code in an image
  • Multiple QR Code Detection: Detect and decode multiple QR codes in a single image
  • Quick Detection: Check if an image contains a QR code without decoding
  • Non-blocking: Uses worker threads for asynchronous processing
  • Multiple Input Formats: Supports both file paths and image buffers
  • Corner Detection: Returns corner coordinates of detected QR codes
  • Base64 Image Export: Extracted QR code region as base64-encoded PNG

Installation

npm install

Prerequisites

  • Node.js >= 14.0.0
  • OpenCV 4.x installed on your system

macOS

brew install opencv

Linux

sudo apt-get install libopencv-dev

Usage

Detect Single QR Code

const { detectQRCode } = require('./qr-detector');

// Using file path
const result = await detectQRCode('/path/to/image.jpg');
console.log(result);
// {
//   detected: true,
//   data: 'https://example.com',
//   corners: [
//     { x: 100, y: 100 },
//     { x: 200, y: 100 },
//     { x: 200, y: 200 },
//     { x: 100, y: 200 }
//   ],
//   qrCodeImage: 'data:image/png;base64,iVBORw0KGgo...'
// }

// Using buffer
const fs = require('fs');
const imageBuffer = fs.readFileSync('/path/to/image.jpg');
const result = await detectQRCode(imageBuffer);

Detect Multiple QR Codes

const { detectMultipleQRCodes } = require('./qr-detector');

const result = await detectMultipleQRCodes('/path/to/image.jpg');
console.log(result);
// {
//   detected: true,
//   count: 2,
//   qrCodes: [
//     {
//       data: 'https://example.com',
//       corners: [...]
//     },
//     {
//       data: 'Another QR code data',
//       corners: [...]
//     }
//   ]
// }

Quick Detection (Without Decoding)

const { hasQRCode } = require('./qr-detector');

const result = await hasQRCode('/path/to/image.jpg');
console.log(result);
// {
//   hasQRCode: true,
//   corners: [...]
// }

API

detectQRCode(input)

Detects and decodes a single QR code in an image.

Parameters:

  • input (string|Buffer): Image file path or buffer

Returns: Promise

  • detected (boolean): Whether a QR code was detected
  • data (string|null): Decoded QR code data
  • corners (Array): Corner points of the QR code
  • qrCodeImage (string): Base64-encoded PNG of extracted QR code (format: data:image/png;base64,...)

detectMultipleQRCodes(input)

Detects and decodes multiple QR codes in an image.

Parameters:

  • input (string|Buffer): Image file path or buffer

Returns: Promise

  • detected (boolean): Whether any QR codes were detected
  • count (number): Number of QR codes detected
  • qrCodes (Array): Array of detected QR codes with data and corners

hasQRCode(input)

Checks if an image contains a QR code without decoding it (faster).

Parameters:

  • input (string|Buffer): Image file path or buffer

Returns: Promise

  • hasQRCode (boolean): Whether a QR code was detected
  • corners (Array): Corner points of the QR code

Architecture

This module follows the same architecture as the camera-sabotage-detector:

  1. C++ Native Addon: Uses OpenCV's QRCodeDetector for high-performance detection
  2. N-API: Ensures compatibility across Node.js versions
  3. Worker Threads: Runs detection in separate threads for non-blocking operation
  4. Multiple Input Formats: Supports both file paths and image buffers

License

MIT