🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

detection-lib

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detection-lib

> A modular JavaScript detection library for face, QR, and future detection types with a clean, unified API.

1.0.11
npm
Version published
Weekly downloads
275
-57.63%
Maintainers
1
Weekly downloads
 
Created
Source

detection-lib

A modular JavaScript detection library for face, QR, and future detection types with a clean, unified API.

Features

  • Pluggable Detectors — Start with face detection and extend easily with QR, object, etc.(currently only have face).
  • Unified Interface — Every detector implements the same async detect(input) method.
  • Factory Pattern — Use createDetector({ type }) to initialize the correct implementation.
  • Works in Browser — Supports <video>, <canvas>, and <img> HTML elements.

Installation

This library currently runs in the browser using ES modules.

Installation

npm install detection-lib

Usage

import { createDetector } from 'detection-lib';

// Create a face detector
const detector = await createDetector({ type: 'face' });

// Detect faces in a video element
const result = await detector.detect(videoElement);

if (result.type === 'face' && result.boxes) {
  result.boxes.forEach(box => {
    // Draw box on canvas, etc.
    console.log(box);
  });
}

API

createDetector(options)

  • options.type: 'face' | 'qr' | string — The type of detector to create.
  • Returns a detector instance with an async detect(input) method

Detector Interface

All detectors implement:

async detect(input: HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): Promise<DetectionResult>

DetectionResult

  • type: string — The detector type ('face', 'qr', etc.)
  • boxes: Array of { x, y, w, h, score? } (for face, etc.)
  • data: Any extra data (for QR, etc.)

Extending

To add a new detector:

1. Create a new file in src/detectors/ (e.g., myDetector.js).
2. Implement a class with a detect() method.
3. Register it in the factory in src/DetectorFactory.js.

FAQs

Package last updated on 09 Jun 2025

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