UNPKG

id-scanner-lib

Version:

Browser-based ID card, QR code, and face recognition scanner with liveness detection

65 lines (64 loc) 1.62 kB
/** * @file 二维码扫描器 * @description 提供二维码检测和解析功能 * @module modules/qrcode/qr-code-scanner */ import { EventEmitter } from '../../core/event-emitter'; import { QRCodeResult } from './types'; /** * 二维码扫描器配置选项 */ export interface QRCodeScannerOptions { /** 最小置信度 */ minConfidence?: number; /** 是否返回原始图像 */ returnImage?: boolean; /** 图像处理配置 */ imageProcess?: { /** 是否进行预处理 */ preprocess?: boolean; /** 是否增强对比度 */ enhanceContrast?: boolean; /** 二值化阈值 */ threshold?: number; }; } /** * 二维码扫描器类 */ export declare class QRCodeScanner extends EventEmitter { private options; private logger; private initialized; /** * 构造函数 * @param options 配置选项 */ constructor(options?: QRCodeScannerOptions); /** * 初始化扫描器 */ initialize(): Promise<void>; /** * 扫描图像中的二维码 * @param image 图像源 * @returns 二维码扫描结果 */ scan(image: ImageData | HTMLImageElement | HTMLCanvasElement): Promise<QRCodeResult | undefined>; /** * 将各种图像源转换为ImageData * @param image 图像源 * @returns ImageData */ private getImageData; /** * 图像预处理 * @param imageData 原始图像数据 * @returns 处理后的图像数据 */ private preprocessImage; /** * 释放资源 */ dispose(): Promise<void>; }