@sssxyd/face-liveness-detector 0.3.5 → 0.4.0-alpha.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.
- package/README.md +61 -45
- package/README.zh-Hans.md +695 -0
- package/dist/index.esm.js +4096 -1368
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4098 -1367
- package/dist/index.js.map +1 -1
- package/dist/types/__tests__/motion-liveness-detector.test.d.ts +6 -0
- package/dist/types/__tests__/motion-liveness-detector.test.d.ts.map +1 -0
- package/dist/types/browser_utils.d.ts +18 -0
- package/dist/types/browser_utils.d.ts.map +1 -0
- package/dist/types/config.d.ts +3 -6
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/enums.d.ts +7 -1
- package/dist/types/enums.d.ts.map +1 -1
- package/dist/types/face-detection-engine.d.ts +132 -0
- package/dist/types/face-detection-engine.d.ts.map +1 -0
- package/dist/types/face-detection-state.d.ts +35 -0
- package/dist/types/face-detection-state.d.ts.map +1 -0
- package/dist/types/face-frontal-calculator.d.ts +130 -0
- package/dist/types/face-frontal-calculator.d.ts.map +1 -0
- package/dist/types/image-quality-calculator.d.ts +66 -0
- package/dist/types/image-quality-calculator.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -191
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/library-loader.d.ts.map +1 -1
- package/dist/types/motion-liveness-detector.d.ts +198 -0
- package/dist/types/motion-liveness-detector.d.ts.map +1 -0
- package/dist/types/screen-capture-detector.d.ts +187 -0
- package/dist/types/screen-capture-detector.d.ts.map +1 -0
- package/dist/types/screen-color-profile-detect.d.ts +77 -0
- package/dist/types/screen-color-profile-detect.d.ts.map +1 -0
- package/dist/types/screen-moire-pattern-detect.d.ts +102 -0
- package/dist/types/screen-moire-pattern-detect.d.ts.map +1 -0
- package/dist/types/screen-rgb-emission-detect.d.ts +42 -0
- package/dist/types/screen-rgb-emission-detect.d.ts.map +1 -0
- package/dist/types/types.d.ts +67 -62
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/uniapp-resource-manager.d.ts +57 -0
- package/dist/types/uniapp-resource-manager.d.ts.map +1 -0
- package/dist/types/uniapp-sdk.d.ts +89 -0
- package/dist/types/uniapp-sdk.d.ts.map +1 -0
- package/package.json +14 -4
- package/dist/types/__tests__/config.test.d.ts +0 -5
- package/dist/types/__tests__/config.test.d.ts.map +0 -1
- package/dist/types/__tests__/enums.test.d.ts +0 -5
- package/dist/types/__tests__/enums.test.d.ts.map +0 -1
- package/dist/types/__tests__/event-emitter.test.d.ts +0 -5
- package/dist/types/__tests__/event-emitter.test.d.ts.map +0 -1
- package/dist/types/__tests__/face-detection-engine.test.d.ts +0 -7
- package/dist/types/__tests__/face-detection-engine.test.d.ts.map +0 -1
- package/dist/types/exports.d.ts +0 -11
- package/dist/types/exports.d.ts.map +0 -1
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* 人脸检测引擎 - 类型定义
|
|
3
|
+
* 用于人脸活体检测的框架无关类型定义
|
|
4
4
|
*/
|
|
5
5
|
import type { LivenessAction, LivenessActionStatus, DetectionCode, ErrorCode } from './enums';
|
|
6
6
|
export interface FaceFrontalFeatures {
|
|
@@ -10,67 +10,68 @@ export interface FaceFrontalFeatures {
|
|
|
10
10
|
}
|
|
11
11
|
export interface ImageQualityFeatures {
|
|
12
12
|
require_full_face_in_bounds: boolean;
|
|
13
|
-
use_opencv_enhancement: boolean;
|
|
14
13
|
min_laplacian_variance: number;
|
|
15
14
|
min_gradient_sharpness: number;
|
|
16
15
|
min_blur_score: number;
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* 人脸检测引擎的主配置接口
|
|
19
|
+
* 所有设置都作为单个属性展平
|
|
21
20
|
*/
|
|
22
|
-
export interface
|
|
21
|
+
export interface FaceDetectionEngineOptions {
|
|
23
22
|
human_model_path?: string;
|
|
24
23
|
tensorflow_wasm_path?: string;
|
|
25
24
|
tensorflow_backend?: 'auto' | 'webgl' | 'wasm';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
liveness_action_count: number;
|
|
70
|
-
liveness_action_randomize: boolean;
|
|
71
|
-
liveness_verify_timeout: number;
|
|
72
|
-
min_mouth_open_percent: number;
|
|
25
|
+
detect_video_ideal_width?: number;
|
|
26
|
+
detect_video_ideal_height?: number;
|
|
27
|
+
detect_video_mirror?: boolean;
|
|
28
|
+
detect_video_load_timeout?: number;
|
|
29
|
+
detect_frame_delay?: number;
|
|
30
|
+
detect_error_retry_delay?: number;
|
|
31
|
+
collect_min_collect_count?: number;
|
|
32
|
+
collect_min_face_ratio?: number;
|
|
33
|
+
collect_max_face_ratio?: number;
|
|
34
|
+
collect_min_face_frontal?: number;
|
|
35
|
+
collect_min_image_quality?: number;
|
|
36
|
+
collect_face_frontal_features?: FaceFrontalFeatures;
|
|
37
|
+
collect_image_quality_features?: ImageQualityFeatures;
|
|
38
|
+
action_liveness_action_list?: LivenessAction[];
|
|
39
|
+
action_liveness_action_count?: number;
|
|
40
|
+
action_liveness_action_randomize?: boolean;
|
|
41
|
+
action_liveness_verify_timeout?: number;
|
|
42
|
+
action_liveness_min_mouth_open_percent?: number;
|
|
43
|
+
motion_liveness_min_motion_score?: number;
|
|
44
|
+
motion_liveness_min_keypoint_variance?: number;
|
|
45
|
+
motion_liveness_frame_buffer_size?: number;
|
|
46
|
+
motion_liveness_eye_aspect_ratio_threshold?: number;
|
|
47
|
+
motion_liveness_motion_consistency_threshold?: number;
|
|
48
|
+
motion_liveness_min_optical_flow_threshold?: number;
|
|
49
|
+
motion_liveness_strict_photo_detection?: boolean;
|
|
50
|
+
screen_capture_confidence_threshold?: number;
|
|
51
|
+
screen_capture_detection_strategy?: 'fastest' | 'fast' | 'accurate' | 'adaptive';
|
|
52
|
+
screen_moire_pattern_threshold?: number;
|
|
53
|
+
screen_moire_pattern_enable_dct?: boolean;
|
|
54
|
+
screen_moire_pattern_enable_edge_detection?: boolean;
|
|
55
|
+
screen_color_saturation_threshold?: number;
|
|
56
|
+
screen_color_rgb_correlation_threshold?: number;
|
|
57
|
+
screen_color_pixel_entropy_threshold?: number;
|
|
58
|
+
screen_color_gradient_smoothness_threshold?: number;
|
|
59
|
+
screen_color_confidence_threshold?: number;
|
|
60
|
+
screen_rgb_low_freq_start_percent?: number;
|
|
61
|
+
screen_rgb_low_freq_end_percent?: number;
|
|
62
|
+
screen_rgb_energy_ratio_normalization_factor?: number;
|
|
63
|
+
screen_rgb_channel_difference_normalization_factor?: number;
|
|
64
|
+
screen_rgb_energy_score_weight?: number;
|
|
65
|
+
screen_rgb_asymmetry_score_weight?: number;
|
|
66
|
+
screen_rgb_difference_factor_weight?: number;
|
|
67
|
+
screen_rgb_confidence_threshold?: number;
|
|
73
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* 与默认值合并后的已解析配置
|
|
71
|
+
* 所有属性都保证为非 undefined
|
|
72
|
+
* 在内部用作 mergeOptions() 的返回类型
|
|
73
|
+
*/
|
|
74
|
+
export type ResolvedEngineOptions = Required<FaceDetectionEngineOptions>;
|
|
74
75
|
export interface DetectorLoadedEventData {
|
|
75
76
|
success: boolean;
|
|
76
77
|
error?: string;
|
|
@@ -82,19 +83,23 @@ export interface DetectorActionEventData {
|
|
|
82
83
|
status: LivenessActionStatus;
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
85
|
-
*
|
|
86
|
+
* 人脸检测信息事件数据
|
|
86
87
|
*/
|
|
87
88
|
export interface DetectorInfoEventData {
|
|
88
89
|
passed: boolean;
|
|
89
90
|
code: DetectionCode;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
message: string;
|
|
92
|
+
faceCount: number;
|
|
93
|
+
faceRatio: number;
|
|
94
|
+
faceFrontal: number;
|
|
95
|
+
imageQuality: number;
|
|
96
|
+
motionScore: number;
|
|
97
|
+
keypointVariance: number;
|
|
98
|
+
motionType: string;
|
|
99
|
+
screenConfidence: number;
|
|
95
100
|
}
|
|
96
101
|
/**
|
|
97
|
-
*
|
|
102
|
+
* 动作/静默活体检测完成数据
|
|
98
103
|
*/
|
|
99
104
|
export interface DetectorFinishEventData {
|
|
100
105
|
success: boolean;
|
|
@@ -106,14 +111,14 @@ export interface DetectorFinishEventData {
|
|
|
106
111
|
bestFaceImage: string | null;
|
|
107
112
|
}
|
|
108
113
|
/**
|
|
109
|
-
*
|
|
114
|
+
* 错误数据
|
|
110
115
|
*/
|
|
111
116
|
export interface DetectorErrorEventData {
|
|
112
117
|
code: ErrorCode;
|
|
113
118
|
message: string;
|
|
114
119
|
}
|
|
115
120
|
/**
|
|
116
|
-
*
|
|
121
|
+
* 调试信息数据
|
|
117
122
|
*/
|
|
118
123
|
export interface DetectorDebugEventData {
|
|
119
124
|
level: 'info' | 'warn' | 'error';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,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;CACzC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Face Detection Engine - UniApp Resource Manager
|
|
3
|
+
* Handles loading of models and WASM files in UniApp environment
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 获取资源路径(考虑 static 目录)
|
|
7
|
+
* 支持 UniApp App、H5、小程序等多个平台
|
|
8
|
+
* @param relativePath - 相对路径(相对于插件的 static 目录)
|
|
9
|
+
* @returns 完整的资源路径
|
|
10
|
+
*/
|
|
11
|
+
export declare function getResourcePath(relativePath: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* 获取模型文件基础路径
|
|
14
|
+
* @returns 模型文件所在目录的路径
|
|
15
|
+
*/
|
|
16
|
+
export declare function getModelBasePath(): string;
|
|
17
|
+
/**
|
|
18
|
+
* 获取 WASM 文件路径
|
|
19
|
+
* @returns WASM 文件所在目录的路径
|
|
20
|
+
*/
|
|
21
|
+
export declare function getWasmPath(): string;
|
|
22
|
+
/**
|
|
23
|
+
* 检查资源是否存在(H5 环境)
|
|
24
|
+
* @param url - 资源 URL
|
|
25
|
+
* @returns Promise<boolean>
|
|
26
|
+
*/
|
|
27
|
+
export declare function checkResourceExists(url: string): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* UniApp 环境检测
|
|
30
|
+
*/
|
|
31
|
+
export declare function detectUniAppEnvironment(): {
|
|
32
|
+
isUniApp: boolean;
|
|
33
|
+
platform: string;
|
|
34
|
+
modelPath: string;
|
|
35
|
+
wasmPath: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 在 UniApp 中初始化资源路径
|
|
39
|
+
* 应该在应用启动时调用
|
|
40
|
+
*/
|
|
41
|
+
export declare function initializeUniAppResources(): void;
|
|
42
|
+
/**
|
|
43
|
+
* 预加载资源文件(可选,用于提前缓存)
|
|
44
|
+
* 加载所有必需的模型文件和 WASM 后端
|
|
45
|
+
*/
|
|
46
|
+
export declare function preloadResources(): Promise<boolean>;
|
|
47
|
+
declare const _default: {
|
|
48
|
+
getResourcePath: typeof getResourcePath;
|
|
49
|
+
getModelBasePath: typeof getModelBasePath;
|
|
50
|
+
getWasmPath: typeof getWasmPath;
|
|
51
|
+
checkResourceExists: typeof checkResourceExists;
|
|
52
|
+
detectUniAppEnvironment: typeof detectUniAppEnvironment;
|
|
53
|
+
initializeUniAppResources: typeof initializeUniAppResources;
|
|
54
|
+
preloadResources: typeof preloadResources;
|
|
55
|
+
};
|
|
56
|
+
export default _default;
|
|
57
|
+
//# sourceMappingURL=uniapp-resource-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniapp-resource-manager.d.ts","sourceRoot":"","sources":["../../src/uniapp-resource-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAsC5D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOvE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI;IACzC,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CA6DA;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAmBhD;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAwGzD;;;;;;;;;;AAED,wBAQC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Face Liveness Detection SDK for UniApp
|
|
3
|
+
* Complete SDK wrapper for UniApp integration
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```javascript
|
|
7
|
+
* import FaceLivenessDetector from '@sssxyd/face-liveness-detector/uniapp'
|
|
8
|
+
*
|
|
9
|
+
* const detector = new FaceLivenessDetector({
|
|
10
|
+
* min_face_ratio: 0.5,
|
|
11
|
+
* max_face_ratio: 0.9,
|
|
12
|
+
* liveness_action_count: 1
|
|
13
|
+
* })
|
|
14
|
+
*
|
|
15
|
+
* detector.on('detector-loaded', () => {
|
|
16
|
+
* console.log('Detector ready')
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* await detector.initialize()
|
|
20
|
+
* await detector.startDetection(videoElement)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import FaceDetectionEngine from './index';
|
|
24
|
+
import type { FaceDetectionEngineOptions } from './types';
|
|
25
|
+
import { detectUniAppEnvironment } from './uniapp-resource-manager';
|
|
26
|
+
/**
|
|
27
|
+
* UniApp Face Liveness Detection SDK
|
|
28
|
+
* Wrapper around FaceDetectionEngine optimized for UniApp
|
|
29
|
+
*/
|
|
30
|
+
export declare class UniAppFaceDetectionEngine extends FaceDetectionEngine {
|
|
31
|
+
private resourcesInitialized;
|
|
32
|
+
private resourcesPreloaded;
|
|
33
|
+
/**
|
|
34
|
+
* Constructor
|
|
35
|
+
* @param config - Configuration object
|
|
36
|
+
*/
|
|
37
|
+
constructor(config?: Partial<FaceDetectionEngineOptions>);
|
|
38
|
+
/**
|
|
39
|
+
* Initialize the detection engine with UniApp optimizations
|
|
40
|
+
* Includes automatic resource preloading for better UX
|
|
41
|
+
*/
|
|
42
|
+
initialize(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Start detection in UniApp
|
|
45
|
+
* Automatically handles platform-specific requirements
|
|
46
|
+
*/
|
|
47
|
+
startDetection(videoElement: HTMLVideoElement): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Get current resource status
|
|
50
|
+
*/
|
|
51
|
+
getResourceStatus(): {
|
|
52
|
+
initialized: boolean;
|
|
53
|
+
preloaded: boolean;
|
|
54
|
+
modelPath: string;
|
|
55
|
+
wasmPath: string;
|
|
56
|
+
environment: ReturnType<typeof detectUniAppEnvironment>;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create and return a new SDK instance
|
|
61
|
+
*
|
|
62
|
+
* @param config - Configuration object
|
|
63
|
+
* @returns SDK instance ready to use
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```javascript
|
|
67
|
+
* import { createSDK } from '@sssxyd/face-liveness-detector/uniapp'
|
|
68
|
+
*
|
|
69
|
+
* const detector = createSDK({
|
|
70
|
+
* liveness_action_count: 2
|
|
71
|
+
* })
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function createSDK(config?: Partial<FaceDetectionEngineOptions>): UniAppFaceDetectionEngine;
|
|
75
|
+
/**
|
|
76
|
+
* Check if environment supports the SDK
|
|
77
|
+
*
|
|
78
|
+
* @returns Object with support information
|
|
79
|
+
*/
|
|
80
|
+
export declare function checkEnvironmentSupport(): {
|
|
81
|
+
isSupported: boolean;
|
|
82
|
+
platform: string;
|
|
83
|
+
reason?: string;
|
|
84
|
+
};
|
|
85
|
+
export type { FaceDetectionEngineOptions, EventEmitter, DetectorFinishEventData, DetectorErrorEventData, DetectorLoadedEventData } from './types';
|
|
86
|
+
export { LivenessAction, ErrorCode, DetectionCode, LivenessActionStatus, DetectionPeriod } from './enums';
|
|
87
|
+
export { getModelBasePath, getWasmPath, detectUniAppEnvironment, initializeUniAppResources, preloadResources } from './uniapp-resource-manager';
|
|
88
|
+
export default UniAppFaceDetectionEngine;
|
|
89
|
+
//# sourceMappingURL=uniapp-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniapp-sdk.d.ts","sourceRoot":"","sources":["../../src/uniapp-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG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AAyB,EACzB,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAElC,eAAe,yBAAyB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@sssxyd/face-liveness-detector",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0-alpha.2",
|
|
5
5
|
"description": "Pure JS/TS implementation of liveness face detection based on human.js and opencv.js",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "rollup -c rollup.config.js",
|
|
33
33
|
"build:watch": "rollup -c rollup.config.js -w",
|
|
34
|
+
"build:uniapp": "rollup -c uniapp/rollup.config.js",
|
|
35
|
+
"package:uniapp": "node uniapp/build.cjs",
|
|
36
|
+
"download-wasm:plugin": "node uniapp/download-wasm-plugin.cjs",
|
|
37
|
+
"install:uniapp": "node uniapp/install-plugin.cjs",
|
|
34
38
|
"dev": "npm run build:watch",
|
|
35
39
|
"clean": "rm -rf dist types",
|
|
36
40
|
"type-check": "tsc --noEmit",
|
|
@@ -58,14 +62,16 @@
|
|
|
58
62
|
}
|
|
59
63
|
},
|
|
60
64
|
"devDependencies": {
|
|
61
|
-
"@techstark/opencv-js": "^4.12.0-release.1",
|
|
62
|
-
"@vladmandic/human": "^3.3.0",
|
|
63
65
|
"@babel/preset-typescript": "^7.28.5",
|
|
64
66
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
65
67
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
68
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
66
69
|
"@rollup/plugin-typescript": "^11.1.5",
|
|
70
|
+
"@techstark/opencv-js": "^4.12.0-release.1",
|
|
67
71
|
"@types/jest": "^30.0.0",
|
|
68
72
|
"@types/node": "^20.8.0",
|
|
73
|
+
"@vladmandic/human": "^3.3.0",
|
|
74
|
+
"fs-extra": "^11.3.2",
|
|
69
75
|
"jest": "^30.2.0",
|
|
70
76
|
"jest-environment-jsdom": "^30.2.0",
|
|
71
77
|
"rollup": "^3.29.4",
|
|
@@ -80,5 +86,9 @@
|
|
|
80
86
|
"bugs": {
|
|
81
87
|
"url": "https://github.com/sssxyd/face-liveness-detector/issues"
|
|
82
88
|
},
|
|
83
|
-
"homepage": "https://github.com/sssxyd/face-liveness-detector#readme"
|
|
89
|
+
"homepage": "https://github.com/sssxyd/face-liveness-detector#readme",
|
|
90
|
+
"docs": {
|
|
91
|
+
"en": "https://github.com/sssxyd/face-liveness-detector/blob/main/README.md",
|
|
92
|
+
"zh": "https://github.com/sssxyd/face-liveness-detector/blob/main/README.zh-Hans.md"
|
|
93
|
+
}
|
|
84
94
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/config.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enums.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/enums.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-emitter.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/event-emitter.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"face-detection-engine.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/face-detection-engine.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/types/exports.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Face Detection Engine
|
|
3
|
-
* Framework-agnostic face liveness detection engine
|
|
4
|
-
*
|
|
5
|
-
* @module @sssxyd/face-liveness-detector
|
|
6
|
-
*/
|
|
7
|
-
export { FaceDetectionEngine, FaceDetectionEngine as default } from './index';
|
|
8
|
-
export { preloadOpenCV, getOpenCVVersion, getCvSync } from './library-loader';
|
|
9
|
-
export type { FaceDetectionEngineConfig, FaceFrontalFeatures, ImageQualityFeatures, DetectorInfoEventData, DetectorActionEventData, DetectorFinishEventData, DetectorErrorEventData, DetectorDebugEventData, DetectorLoadedEventData, EventMap, EventListener, EventEmitter, ResolvedEngineConfig } from './types';
|
|
10
|
-
export { LivenessAction, LivenessActionStatus, DetectionCode, ErrorCode, DetectionPeriod } from './enums';
|
|
11
|
-
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,IAAI,OAAO,EAAE,MAAM,SAAS,CAAA;AAG7E,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAG7E,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,eAAe,EAChB,MAAM,SAAS,CAAA"}
|