id-scanner-lib 1.2.2 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +375 -363
  3. package/dist/id-scanner-core.esm.js +427 -221
  4. package/dist/id-scanner-core.esm.js.map +1 -1
  5. package/dist/id-scanner-core.js +427 -221
  6. package/dist/id-scanner-core.js.map +1 -1
  7. package/dist/id-scanner-core.min.js +1 -9
  8. package/dist/id-scanner-core.min.js.map +1 -1
  9. package/dist/id-scanner-ocr.esm.js +451 -276
  10. package/dist/id-scanner-ocr.esm.js.map +1 -1
  11. package/dist/id-scanner-ocr.js +451 -276
  12. package/dist/id-scanner-ocr.js.map +1 -1
  13. package/dist/id-scanner-ocr.min.js +1 -9
  14. package/dist/id-scanner-ocr.min.js.map +1 -1
  15. package/dist/id-scanner-qr.esm.js +483 -233
  16. package/dist/id-scanner-qr.esm.js.map +1 -1
  17. package/dist/id-scanner-qr.js +482 -232
  18. package/dist/id-scanner-qr.js.map +1 -1
  19. package/dist/id-scanner-qr.min.js +1 -9
  20. package/dist/id-scanner-qr.min.js.map +1 -1
  21. package/dist/id-scanner.js +2138 -358
  22. package/dist/id-scanner.js.map +1 -1
  23. package/dist/id-scanner.min.js +1 -9
  24. package/dist/id-scanner.min.js.map +1 -1
  25. package/package.json +27 -7
  26. package/src/demo/demo.ts +178 -62
  27. package/src/id-recognition/anti-fake-detector.ts +317 -0
  28. package/src/id-recognition/id-detector.ts +184 -155
  29. package/src/id-recognition/ocr-processor.ts +193 -146
  30. package/src/id-recognition/ocr-worker.ts +82 -72
  31. package/src/index-umd.ts +347 -110
  32. package/src/index.ts +866 -91
  33. package/src/ocr-module.ts +108 -60
  34. package/src/qr-module.ts +104 -54
  35. package/src/scanner/barcode-scanner.ts +145 -58
  36. package/src/scanner/qr-scanner.ts +86 -47
  37. package/src/utils/image-processing.ts +479 -294
  38. package/dist/core.d.ts +0 -77
  39. package/dist/demo/demo.d.ts +0 -14
  40. package/dist/id-recognition/data-extractor.d.ts +0 -105
  41. package/dist/id-recognition/id-detector.d.ts +0 -100
  42. package/dist/id-recognition/ocr-processor.d.ts +0 -64
  43. package/dist/id-scanner.esm.js +0 -94656
  44. package/dist/id-scanner.esm.js.map +0 -1
  45. package/dist/index-umd.d.ts +0 -96
  46. package/dist/index.d.ts +0 -78
  47. package/dist/ocr-module.d.ts +0 -67
  48. package/dist/qr-module.d.ts +0 -68
  49. package/dist/scanner/barcode-scanner.d.ts +0 -90
  50. package/dist/scanner/qr-scanner.d.ts +0 -80
  51. package/dist/types/core.d.ts +0 -77
  52. package/dist/types/demo/demo.d.ts +0 -14
  53. package/dist/types/id-recognition/data-extractor.d.ts +0 -105
  54. package/dist/types/id-recognition/id-detector.d.ts +0 -100
  55. package/dist/types/id-recognition/ocr-processor.d.ts +0 -64
  56. package/dist/types/index-umd.d.ts +0 -96
  57. package/dist/types/index.d.ts +0 -78
  58. package/dist/types/ocr-module.d.ts +0 -67
  59. package/dist/types/qr-module.d.ts +0 -68
  60. package/dist/types/scanner/barcode-scanner.d.ts +0 -90
  61. package/dist/types/scanner/qr-scanner.d.ts +0 -80
  62. package/dist/types/utils/camera.d.ts +0 -81
  63. package/dist/types/utils/image-processing.d.ts +0 -75
  64. package/dist/types/utils/types.d.ts +0 -65
  65. package/dist/utils/camera.d.ts +0 -81
  66. package/dist/utils/image-processing.d.ts +0 -75
  67. package/dist/utils/types.d.ts +0 -65
@@ -1,100 +0,0 @@
1
- /**
2
- * @file 身份证检测模块
3
- * @description 提供自动检测和定位图像中的身份证功能
4
- * @module IDCardDetector
5
- */
6
- /**
7
- * DetectionResult接口
8
- *
9
- * 包含身份证检测结果信息
10
- */
11
- export interface DetectionResult {
12
- success: boolean;
13
- imageData?: ImageData;
14
- boundingBox?: {
15
- x: number;
16
- y: number;
17
- width: number;
18
- height: number;
19
- };
20
- confidence?: number;
21
- message?: string;
22
- }
23
- /**
24
- * IDCardDetector配置选项
25
- */
26
- export interface IDCardDetectorOptions {
27
- onDetection?: (result: DetectionResult) => void;
28
- onError?: (error: Error) => void;
29
- detectionInterval?: number;
30
- }
31
- /**
32
- * 身份证检测器类
33
- *
34
- * 通过图像处理和计算机视觉技术,实时检测视频流中的身份证,并提取身份证区域
35
- * 注意:当前实现是简化版,实际项目中建议使用OpenCV.js进行更精确的检测
36
- *
37
- * @example
38
- * ```typescript
39
- * // 创建身份证检测器
40
- * const detector = new IDCardDetector((result) => {
41
- * if (result.success && result.croppedImage) {
42
- * console.log('检测到身份证!');
43
- * // 对裁剪出的身份证图像进行处理
44
- * processIDCardImage(result.croppedImage);
45
- * }
46
- * });
47
- *
48
- * // 启动检测
49
- * const videoElement = document.getElementById('video') as HTMLVideoElement;
50
- * await detector.start(videoElement);
51
- *
52
- * // 停止检测
53
- * detector.stop();
54
- * ```
55
- */
56
- export declare class IDCardDetector {
57
- private onDetected?;
58
- private camera;
59
- private detecting;
60
- private detectTimer;
61
- /**
62
- * 创建身份证检测器实例
63
- *
64
- * @param {Function} [onDetected] - 身份证检测成功回调函数,接收检测结果对象
65
- */
66
- constructor(onDetected?: ((result: DetectionResult) => void) | undefined);
67
- /**
68
- * 启动身份证检测
69
- *
70
- * 初始化相机并开始连续检测视频帧中的身份证
71
- *
72
- * @param {HTMLVideoElement} videoElement - 用于显示相机画面的video元素
73
- * @returns {Promise<void>} 启动完成的Promise
74
- */
75
- start(videoElement: HTMLVideoElement): Promise<void>;
76
- /**
77
- * 执行一次身份证检测
78
- *
79
- * 内部方法,捕获当前视频帧并尝试检测其中的身份证
80
- *
81
- * @private
82
- */
83
- private detect;
84
- /**
85
- * 身份证检测核心算法
86
- *
87
- * 通过图像处理技术检测和提取图像中的身份证区域
88
- *
89
- * @private
90
- * @param {ImageData} imageData - 需要检测身份证的图像数据
91
- * @returns {Promise<DetectionResult>} 检测结果,包含成功标志和裁剪后的身份证图像
92
- */
93
- private detectIDCard;
94
- /**
95
- * 停止身份证检测
96
- *
97
- * 停止检测循环并释放相机资源
98
- */
99
- stop(): void;
100
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * @file OCR处理模块
3
- * @description 提供身份证文字识别和信息提取功能
4
- * @module OCRProcessor
5
- */
6
- import { IDCardInfo } from '../utils/types';
7
- /**
8
- * OCR处理器类
9
- *
10
- * 使用Tesseract.js实现对身份证图像的OCR文字识别和信息提取功能
11
- *
12
- * @example
13
- * ```typescript
14
- * // 创建OCR处理器
15
- * const ocrProcessor = new OCRProcessor();
16
- *
17
- * // 初始化OCR引擎
18
- * await ocrProcessor.initialize();
19
- *
20
- * // 处理身份证图像
21
- * const idInfo = await ocrProcessor.processIDCard(idCardImageData);
22
- * console.log('识别到的身份证信息:', idInfo);
23
- *
24
- * // 使用结束后释放资源
25
- * await ocrProcessor.terminate();
26
- * ```
27
- */
28
- export declare class OCRProcessor {
29
- private worker;
30
- constructor();
31
- /**
32
- * 初始化OCR引擎
33
- *
34
- * 加载Tesseract OCR引擎和中文简体语言包,并设置适合身份证识别的参数
35
- *
36
- * @returns {Promise<void>} 初始化完成的Promise
37
- */
38
- initialize(): Promise<void>;
39
- /**
40
- * 处理身份证图像并提取信息
41
- *
42
- * 对身份证图像进行OCR识别,并从识别结果中提取结构化信息
43
- *
44
- * @param {ImageData} imageData - 身份证图像数据
45
- * @returns {Promise<IDCardInfo>} 提取到的身份证信息
46
- */
47
- processIDCard(imageData: ImageData): Promise<IDCardInfo>;
48
- /**
49
- * 解析身份证文本信息
50
- *
51
- * 从OCR识别到的文本中提取结构化的身份证信息
52
- *
53
- * @private
54
- * @param {string} text - OCR识别到的文本
55
- * @returns {IDCardInfo} 提取到的身份证信息对象
56
- */
57
- private parseIDCardText;
58
- /**
59
- * 终止OCR引擎并释放资源
60
- *
61
- * @returns {Promise<void>} 终止完成的Promise
62
- */
63
- terminate(): Promise<void>;
64
- }
@@ -1,96 +0,0 @@
1
- /**
2
- * @file ID扫描识别库UMD格式入口文件
3
- * @description 专门为UMD格式构建的入口,使用静态导入而非动态导入
4
- * @module IDScannerLib
5
- * @version 1.1.0
6
- * @license MIT
7
- */
8
- import { CameraOptions } from './utils/camera';
9
- import { IDCardInfo } from './utils/types';
10
- import type { QRScannerOptions } from './scanner/qr-scanner';
11
- import type { BarcodeScannerOptions } from './scanner/barcode-scanner';
12
- import { QRScanner } from './scanner/qr-scanner';
13
- import { BarcodeScanner } from './scanner/barcode-scanner';
14
- import { IDCardDetector } from './id-recognition/id-detector';
15
- import { OCRProcessor } from './id-recognition/ocr-processor';
16
- import { DataExtractor } from './id-recognition/data-extractor';
17
- import { ImageProcessor } from './utils/image-processing';
18
- /**
19
- * IDScanner配置选项接口
20
- */
21
- export interface IDScannerOptions {
22
- cameraOptions?: CameraOptions;
23
- qrScannerOptions?: QRScannerOptions;
24
- barcodeScannerOptions?: BarcodeScannerOptions;
25
- onQRCodeScanned?: (result: string) => void;
26
- onBarcodeScanned?: (result: string) => void;
27
- onIDCardScanned?: (info: IDCardInfo) => void;
28
- onError?: (error: Error) => void;
29
- }
30
- /**
31
- * IDScanner 主类
32
- * UMD版本使用静态导入实现
33
- */
34
- export declare class IDScanner {
35
- private options;
36
- private camera;
37
- private qrScanner;
38
- private barcodeScanner;
39
- private idDetector;
40
- private ocrProcessor;
41
- private dataExtractor;
42
- private scanMode;
43
- private videoElement;
44
- /**
45
- * 构造函数
46
- * @param options 配置选项
47
- */
48
- constructor(options?: IDScannerOptions);
49
- /**
50
- * 初始化模块
51
- * 根据需要初始化OCR引擎
52
- */
53
- initialize(): Promise<void>;
54
- /**
55
- * 启动二维码扫描
56
- * @param videoElement HTML视频元素
57
- */
58
- startQRScanner(videoElement: HTMLVideoElement): Promise<void>;
59
- /**
60
- * 启动条形码扫描
61
- * @param videoElement HTML视频元素
62
- */
63
- startBarcodeScanner(videoElement: HTMLVideoElement): Promise<void>;
64
- /**
65
- * 启动身份证扫描
66
- * @param videoElement HTML视频元素
67
- */
68
- startIDCardScanner(videoElement: HTMLVideoElement): Promise<void>;
69
- /**
70
- * 停止扫描
71
- */
72
- stop(): void;
73
- /**
74
- * 处理二维码扫描结果
75
- */
76
- private handleQRScan;
77
- /**
78
- * 处理条形码扫描结果
79
- */
80
- private handleBarcodeScan;
81
- /**
82
- * 处理身份证检测结果
83
- */
84
- private handleIDDetection;
85
- /**
86
- * 处理错误
87
- */
88
- private handleError;
89
- /**
90
- * 释放资源
91
- */
92
- terminate(): Promise<void>;
93
- }
94
- export { IDCardInfo } from './utils/types';
95
- export { CameraOptions } from './utils/camera';
96
- export { QRScanner, BarcodeScanner, IDCardDetector, OCRProcessor, DataExtractor, ImageProcessor };
@@ -1,78 +0,0 @@
1
- /**
2
- * @file ID扫描识别库主入口文件
3
- * @description 提供身份证识别与二维码、条形码扫描功能的纯前端TypeScript库
4
- * @module IDScannerLib
5
- * @version 1.0.0
6
- * @license MIT
7
- */
8
- import { CameraOptions } from './utils/camera';
9
- import { IDCardInfo } from './utils/types';
10
- import type { QRScannerOptions } from './scanner/qr-scanner';
11
- import type { BarcodeScannerOptions } from './scanner/barcode-scanner';
12
- /**
13
- * IDScanner配置选项接口
14
- */
15
- export interface IDScannerOptions {
16
- cameraOptions?: CameraOptions;
17
- qrScannerOptions?: QRScannerOptions;
18
- barcodeScannerOptions?: BarcodeScannerOptions;
19
- onQRCodeScanned?: (result: string) => void;
20
- onBarcodeScanned?: (result: string) => void;
21
- onIDCardScanned?: (info: IDCardInfo) => void;
22
- onError?: (error: Error) => void;
23
- }
24
- /**
25
- * IDScanner 主类
26
- *
27
- * 整合二维码、条形码扫描和身份证识别功能,提供统一的接口
28
- * 使用动态导入实现按需加载
29
- */
30
- export declare class IDScanner {
31
- private options;
32
- private camera;
33
- private scanMode;
34
- private videoElement;
35
- private qrModule;
36
- private ocrModule;
37
- private isQRModuleLoaded;
38
- private isOCRModuleLoaded;
39
- /**
40
- * 构造函数
41
- * @param options 配置选项
42
- */
43
- constructor(options?: IDScannerOptions);
44
- /**
45
- * 初始化模块
46
- * 根据需要初始化OCR引擎
47
- */
48
- initialize(): Promise<void>;
49
- /**
50
- * 启动二维码扫描
51
- * @param videoElement HTML视频元素
52
- */
53
- startQRScanner(videoElement: HTMLVideoElement): Promise<void>;
54
- /**
55
- * 启动条形码扫描
56
- * @param videoElement HTML视频元素
57
- */
58
- startBarcodeScanner(videoElement: HTMLVideoElement): Promise<void>;
59
- /**
60
- * 启动身份证扫描
61
- * @param videoElement HTML视频元素
62
- */
63
- startIDCardScanner(videoElement: HTMLVideoElement): Promise<void>;
64
- /**
65
- * 停止扫描
66
- */
67
- stop(): void;
68
- /**
69
- * 处理错误
70
- */
71
- private handleError;
72
- /**
73
- * 释放资源
74
- */
75
- terminate(): Promise<void>;
76
- }
77
- export { IDCardInfo } from './utils/types';
78
- export { CameraOptions } from './utils/camera';
@@ -1,67 +0,0 @@
1
- /**
2
- * @file OCR模块入口文件
3
- * @description 包含身份证OCR识别相关功能
4
- * @module IDScannerOCR
5
- * @version 1.0.0
6
- * @license MIT
7
- */
8
- import { IDCardInfo } from './utils/types';
9
- import { CameraOptions } from './utils/camera';
10
- /**
11
- * OCR模块配置选项
12
- */
13
- export interface OCRModuleOptions {
14
- cameraOptions?: CameraOptions;
15
- onIDCardScanned?: (info: IDCardInfo) => void;
16
- onError?: (error: Error) => void;
17
- }
18
- /**
19
- * OCR模块类
20
- *
21
- * 提供身份证检测和OCR文字识别功能
22
- */
23
- export declare class OCRModule {
24
- private options;
25
- private idDetector;
26
- private ocrProcessor;
27
- private dataExtractor;
28
- private camera;
29
- private isRunning;
30
- private videoElement;
31
- /**
32
- * 构造函数
33
- * @param options 配置选项
34
- */
35
- constructor(options?: OCRModuleOptions);
36
- /**
37
- * 初始化OCR引擎
38
- *
39
- * @returns Promise<void>
40
- */
41
- initialize(): Promise<void>;
42
- /**
43
- * 启动身份证扫描
44
- * @param videoElement HTML视频元素
45
- */
46
- startIDCardScanner(videoElement: HTMLVideoElement): Promise<void>;
47
- /**
48
- * 停止扫描
49
- */
50
- stop(): void;
51
- /**
52
- * 处理身份证检测结果
53
- */
54
- private handleIDDetection;
55
- /**
56
- * 处理错误
57
- */
58
- private handleError;
59
- /**
60
- * 释放资源
61
- */
62
- terminate(): Promise<void>;
63
- }
64
- export { IDCardDetector } from './id-recognition/id-detector';
65
- export { OCRProcessor } from './id-recognition/ocr-processor';
66
- export { DataExtractor } from './id-recognition/data-extractor';
67
- export { IDCardInfo } from './utils/types';
@@ -1,68 +0,0 @@
1
- /**
2
- * @file 二维码和条形码扫描模块
3
- * @description 包含二维码和条形码扫描功能
4
- * @module IDScannerQR
5
- * @version 1.0.0
6
- * @license MIT
7
- */
8
- import { QRScannerOptions } from './scanner/qr-scanner';
9
- import { BarcodeScannerOptions } from './scanner/barcode-scanner';
10
- import { CameraOptions } from './utils/camera';
11
- /**
12
- * 扫描模块配置选项
13
- */
14
- export interface ScannerModuleOptions {
15
- cameraOptions?: CameraOptions;
16
- qrScannerOptions?: QRScannerOptions;
17
- barcodeScannerOptions?: BarcodeScannerOptions;
18
- onQRCodeScanned?: (result: string) => void;
19
- onBarcodeScanned?: (result: string) => void;
20
- onError?: (error: Error) => void;
21
- }
22
- /**
23
- * 扫描模块类
24
- *
25
- * 提供独立的二维码和条形码扫描功能
26
- */
27
- export declare class ScannerModule {
28
- private options;
29
- private qrScanner;
30
- private barcodeScanner;
31
- private camera;
32
- private scanMode;
33
- private videoElement;
34
- /**
35
- * 构造函数
36
- * @param options 配置选项
37
- */
38
- constructor(options?: ScannerModuleOptions);
39
- /**
40
- * 启动二维码扫描
41
- * @param videoElement HTML视频元素
42
- */
43
- startQRScanner(videoElement: HTMLVideoElement): Promise<void>;
44
- /**
45
- * 启动条形码扫描
46
- * @param videoElement HTML视频元素
47
- */
48
- startBarcodeScanner(videoElement: HTMLVideoElement): Promise<void>;
49
- /**
50
- * 停止扫描
51
- */
52
- stop(): void;
53
- /**
54
- * 处理二维码扫描结果
55
- */
56
- private handleQRScan;
57
- /**
58
- * 处理条形码扫描结果
59
- */
60
- private handleBarcodeScan;
61
- /**
62
- * 处理错误
63
- */
64
- private handleError;
65
- }
66
- export { QRScanner, QRScannerOptions } from './scanner/qr-scanner';
67
- export { BarcodeScanner, BarcodeScannerOptions } from './scanner/barcode-scanner';
68
- export { Camera, CameraOptions } from './utils/camera';
@@ -1,90 +0,0 @@
1
- /**
2
- * @file 条形码扫描模块
3
- * @description 提供实时条形码扫描和识别功能
4
- * @module BarcodeScanner
5
- */
6
- /**
7
- * 条形码扫描器配置选项
8
- *
9
- * @interface BarcodeScannerOptions
10
- * @property {number} [scanInterval] - 扫描间隔时间(毫秒),默认为200ms
11
- * @property {Function} [onScan] - 扫描成功回调函数
12
- * @property {Function} [onError] - 错误处理回调函数
13
- */
14
- export interface BarcodeScannerOptions {
15
- scanInterval?: number;
16
- onScan?: (result: string) => void;
17
- onError?: (error: Error) => void;
18
- }
19
- /**
20
- * 条形码扫描器类
21
- *
22
- * 提供实时扫描和识别摄像头中的条形码的功能
23
- * 注意:当前实现是简化版,实际项目中建议集成专门的条形码识别库如ZXing或Quagga.js
24
- *
25
- * @example
26
- * ```typescript
27
- * // 创建条形码扫描器
28
- * const barcodeScanner = new BarcodeScanner({
29
- * scanInterval: 100, // 每100ms扫描一次
30
- * onScan: (result) => {
31
- * console.log('扫描到条形码:', result);
32
- * },
33
- * onError: (error) => {
34
- * console.error('扫描错误:', error);
35
- * }
36
- * });
37
- *
38
- * // 启动扫描
39
- * const videoElement = document.getElementById('video') as HTMLVideoElement;
40
- * await barcodeScanner.start(videoElement);
41
- *
42
- * // 停止扫描
43
- * barcodeScanner.stop();
44
- * ```
45
- */
46
- export declare class BarcodeScanner {
47
- private options;
48
- private camera;
49
- private scanning;
50
- private scanTimer;
51
- /**
52
- * 创建条形码扫描器实例
53
- *
54
- * @param {BarcodeScannerOptions} [options] - 扫描器配置选项
55
- */
56
- constructor(options?: BarcodeScannerOptions);
57
- /**
58
- * 启动条形码扫描
59
- *
60
- * 初始化相机并开始连续扫描视频帧中的条形码
61
- *
62
- * @param {HTMLVideoElement} videoElement - 用于显示相机画面的video元素
63
- * @returns {Promise<void>} 启动完成的Promise
64
- * @throws 如果无法访问相机,将通过onError回调报告错误
65
- */
66
- start(videoElement: HTMLVideoElement): Promise<void>;
67
- /**
68
- * 执行一次条形码扫描
69
- *
70
- * 内部方法,捕获当前视频帧并尝试识别其中的条形码
71
- *
72
- * @private
73
- */
74
- private scan;
75
- /**
76
- * 条形码检测方法
77
- *
78
- * 注意:这是一个简化实现,实际需要集成专门的条形码识别库
79
- *
80
- * @private
81
- * @param {ImageData} imageData - 要检测条形码的图像数据
82
- */
83
- private detectBarcode;
84
- /**
85
- * 停止条形码扫描
86
- *
87
- * 停止扫描循环并释放相机资源
88
- */
89
- stop(): void;
90
- }
@@ -1,80 +0,0 @@
1
- /**
2
- * @file 二维码扫描模块
3
- * @description 提供实时二维码扫描和识别功能
4
- * @module QRScanner
5
- */
6
- /**
7
- * 二维码扫描器配置选项
8
- *
9
- * @interface QRScannerOptions
10
- * @property {number} [scanInterval] - 扫描间隔时间(毫秒),默认为200ms
11
- * @property {Function} [onScan] - 扫描成功回调函数
12
- * @property {Function} [onError] - 错误处理回调函数
13
- */
14
- export interface QRScannerOptions {
15
- scanInterval?: number;
16
- onScan?: (result: string) => void;
17
- onError?: (error: Error) => void;
18
- }
19
- /**
20
- * 二维码扫描器类
21
- *
22
- * 提供实时扫描和识别摄像头中的二维码的功能
23
- *
24
- * @example
25
- * ```typescript
26
- * // 创建二维码扫描器
27
- * const qrScanner = new QRScanner({
28
- * scanInterval: 100, // 每100ms扫描一次
29
- * onScan: (result) => {
30
- * console.log('扫描到二维码:', result);
31
- * },
32
- * onError: (error) => {
33
- * console.error('扫描错误:', error);
34
- * }
35
- * });
36
- *
37
- * // 启动扫描
38
- * const videoElement = document.getElementById('video') as HTMLVideoElement;
39
- * await qrScanner.start(videoElement);
40
- *
41
- * // 停止扫描
42
- * qrScanner.stop();
43
- * ```
44
- */
45
- export declare class QRScanner {
46
- private options;
47
- private camera;
48
- private scanning;
49
- private scanTimer;
50
- /**
51
- * 创建二维码扫描器实例
52
- *
53
- * @param {QRScannerOptions} [options] - 扫描器配置选项
54
- */
55
- constructor(options?: QRScannerOptions);
56
- /**
57
- * 启动二维码扫描
58
- *
59
- * 初始化相机并开始连续扫描视频帧中的二维码
60
- *
61
- * @param {HTMLVideoElement} videoElement - 用于显示相机画面的video元素
62
- * @returns {Promise<void>} 启动完成的Promise
63
- * @throws 如果无法访问相机,将通过onError回调报告错误
64
- */
65
- start(videoElement: HTMLVideoElement): Promise<void>;
66
- /**
67
- * 执行一次二维码扫描
68
- *
69
- * 内部方法,捕获当前视频帧并尝试识别其中的二维码
70
- *
71
- * @private
72
- */
73
- private scan;
74
- /**
75
- * 停止二维码扫描
76
- *
77
- * 停止扫描循环并释放相机资源
78
- */
79
- stop(): void;
80
- }