@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.
Files changed (52) hide show
  1. package/README.md +61 -45
  2. package/README.zh-Hans.md +695 -0
  3. package/dist/index.esm.js +4096 -1368
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +4098 -1367
  6. package/dist/index.js.map +1 -1
  7. package/dist/types/__tests__/motion-liveness-detector.test.d.ts +6 -0
  8. package/dist/types/__tests__/motion-liveness-detector.test.d.ts.map +1 -0
  9. package/dist/types/browser_utils.d.ts +18 -0
  10. package/dist/types/browser_utils.d.ts.map +1 -0
  11. package/dist/types/config.d.ts +3 -6
  12. package/dist/types/config.d.ts.map +1 -1
  13. package/dist/types/enums.d.ts +7 -1
  14. package/dist/types/enums.d.ts.map +1 -1
  15. package/dist/types/face-detection-engine.d.ts +132 -0
  16. package/dist/types/face-detection-engine.d.ts.map +1 -0
  17. package/dist/types/face-detection-state.d.ts +35 -0
  18. package/dist/types/face-detection-state.d.ts.map +1 -0
  19. package/dist/types/face-frontal-calculator.d.ts +130 -0
  20. package/dist/types/face-frontal-calculator.d.ts.map +1 -0
  21. package/dist/types/image-quality-calculator.d.ts +66 -0
  22. package/dist/types/image-quality-calculator.d.ts.map +1 -0
  23. package/dist/types/index.d.ts +5 -191
  24. package/dist/types/index.d.ts.map +1 -1
  25. package/dist/types/library-loader.d.ts.map +1 -1
  26. package/dist/types/motion-liveness-detector.d.ts +198 -0
  27. package/dist/types/motion-liveness-detector.d.ts.map +1 -0
  28. package/dist/types/screen-capture-detector.d.ts +187 -0
  29. package/dist/types/screen-capture-detector.d.ts.map +1 -0
  30. package/dist/types/screen-color-profile-detect.d.ts +77 -0
  31. package/dist/types/screen-color-profile-detect.d.ts.map +1 -0
  32. package/dist/types/screen-moire-pattern-detect.d.ts +102 -0
  33. package/dist/types/screen-moire-pattern-detect.d.ts.map +1 -0
  34. package/dist/types/screen-rgb-emission-detect.d.ts +42 -0
  35. package/dist/types/screen-rgb-emission-detect.d.ts.map +1 -0
  36. package/dist/types/types.d.ts +67 -62
  37. package/dist/types/types.d.ts.map +1 -1
  38. package/dist/types/uniapp-resource-manager.d.ts +57 -0
  39. package/dist/types/uniapp-resource-manager.d.ts.map +1 -0
  40. package/dist/types/uniapp-sdk.d.ts +89 -0
  41. package/dist/types/uniapp-sdk.d.ts.map +1 -0
  42. package/package.json +14 -4
  43. package/dist/types/__tests__/config.test.d.ts +0 -5
  44. package/dist/types/__tests__/config.test.d.ts.map +0 -1
  45. package/dist/types/__tests__/enums.test.d.ts +0 -5
  46. package/dist/types/__tests__/enums.test.d.ts.map +0 -1
  47. package/dist/types/__tests__/event-emitter.test.d.ts +0 -5
  48. package/dist/types/__tests__/event-emitter.test.d.ts.map +0 -1
  49. package/dist/types/__tests__/face-detection-engine.test.d.ts +0 -7
  50. package/dist/types/__tests__/face-detection-engine.test.d.ts.map +0 -1
  51. package/dist/types/exports.d.ts +0 -11
  52. package/dist/types/exports.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ > **Languages:** [English](#) · [中文](./README.zh-Hans.md)
2
+
1
3
  # Face Detection Engine
2
4
 
3
5
  A pure frontend, real-time face liveness detection engine built on **[Human.js](https://github.com/vladmandic/human)** and **[OpenCV.js](https://github.com/TechStark/opencv-js)**. This TypeScript-based npm package provides real-time face detection, dual liveness verification (silent + action-based), automatic best frame selection, and anti-spoofing capabilities - all running 100% in the browser with zero backend dependency.
@@ -9,7 +11,6 @@ A pure frontend, real-time face liveness detection engine built on **[Human.js](
9
11
  - 🧠 **Dual Detection Modes** - Both silent liveness detection and action-based detection (blink, mouth open, nod) with automatic best frame selection
10
12
  - ⚡ **Pure JavaScript & Event-Driven** - 100% TypeScript, reactive event architecture, seamless integration with any frontend framework (Vue, React, Angular, Svelte, or vanilla JS)
11
13
  - 🎯 **Comprehensive Face Analysis** - Real-time anti-spoofing, quality assessment, frontality detection, and blur detection
12
- - 🛡️ **Advanced Anti-Spoofing** - Real-time liveness score and spoofing detection
13
14
 
14
15
  ## 🚀 Try Online Demo
15
16
 
@@ -149,51 +150,66 @@ runDetection()
149
150
 
150
151
  ### FaceDetectionEngineConfig
151
152
 
152
- ```typescript
153
- interface FaceDetectionEngineConfig {
154
- // ========== Resource Paths ==========
155
- human_model_path?: string // Path to human.js models (default: undefined)
156
- tensorflow_wasm_path?: string // Path to TensorFlow WASM files (default: undefined)
157
- tensorflow_backend?: 'auto' | 'webgl' | 'wasm' // TensorFlow backend selection (default: 'auto')
158
-
159
- // ========== Detection Settings ==========
160
- video_width?: number // Width of the video stream (default: 640)
161
- video_height?: number // Height of the video stream (default: 640)
162
- video_mirror?: boolean // Mirror video horizontally (default: true)
163
- video_load_timeout?: number // Timeout for loading video stream in ms (default: 5000)
164
- detection_frame_delay?: number // Delay between detection frames in ms (default: 100)
165
- error_retry_delay?: number // Delay before retrying after an error in ms (default: 200)
166
-
167
- // ========== Collection Settings ==========
168
- silent_detect_count?: number // Number of silent detections to collect (default: 3)
169
- min_face_ratio?: number // Minimum face size ratio (default: 0.5)
170
- max_face_ratio?: number // Maximum face size ratio (default: 0.9)
171
- min_face_frontal?: number // Minimum face frontality (default: 0.9)
172
- min_image_quality?: number // Minimum image quality (default: 0.5)
173
- min_live_score?: number // Minimum live score (default: 0.5)
174
- min_real_score?: number // Minimum anti-spoofing score (default: 0.85)
175
- suspected_frauds_count?: number // Number of suspected frauds to detect (default: 3)
176
- face_frontal_features?: { // Face frontal features
177
- yaw_threshold: number // Yaw angle threshold in degrees (default: 3)
178
- pitch_threshold: number // Pitch angle threshold in degrees (default: 4)
179
- roll_threshold: number // Roll angle threshold in degrees (default: 2)
180
- }
181
- image_quality_features?: { // Image quality features
182
- require_full_face_in_bounds: boolean // Require face completely within bounds (default: false)
183
- use_opencv_enhancement: boolean // Use OpenCV enhancement for quality detection (default: true)
184
- min_laplacian_variance: number // Minimum Laplacian variance for blur detection (default: 50)
185
- min_gradient_sharpness: number // Minimum gradient sharpness for blur detection (default: 0.15)
186
- min_blur_score: number // Minimum blur score for blur detection (default: 0.6)
187
- }
153
+ #### Resource Paths
154
+
155
+ | Property | Type | Description | Default |
156
+ |----------|------|-------------|---------|
157
+ | `human_model_path` | `string` | Path to Human.js model files | `undefined` |
158
+ | `tensorflow_wasm_path` | `string` | Path to TensorFlow WASM files | `undefined` |
159
+ | `tensorflow_backend` | `'auto' \| 'webgl' \| 'wasm'` | TensorFlow backend selection | `'auto'` |
160
+
161
+ #### Video Detection Settings
162
+
163
+ | Property | Type | Description | Default |
164
+ |----------|------|-------------|---------|
165
+ | `video_width` | `number` | Video stream width in pixels | `640` |
166
+ | `video_height` | `number` | Video stream height in pixels | `640` |
167
+ | `video_mirror` | `boolean` | Mirror video horizontally | `true` |
168
+ | `video_load_timeout` | `number` | Video stream loading timeout in ms | `5000` |
169
+ | `detection_frame_delay` | `number` | Delay between detection frames in ms | `100` |
170
+ | `error_retry_delay` | `number` | Error retry delay in ms | `200` |
171
+
172
+ #### Detection Quality Settings
173
+
174
+ | Property | Type | Description | Default |
175
+ |----------|------|-------------|---------|
176
+ | `silent_detect_count` | `number` | Number of silent detections to collect | `3` |
177
+ | `min_face_ratio` | `number` | Minimum face size ratio (0-1) | `0.5` |
178
+ | `max_face_ratio` | `number` | Maximum face size ratio (0-1) | `0.9` |
179
+ | `min_face_frontal` | `number` | Minimum face frontality score (0-1) | `0.9` |
180
+ | `min_image_quality` | `number` | Minimum image quality score (0-1) | `0.5` |
181
+ | `min_live_score` | `number` | Minimum liveness score (0-1) | `0.5` |
182
+ | `min_real_score` | `number` | Minimum anti-spoofing score (0-1) | `0.85` |
183
+ | `suspected_frauds_count` | `number` | Number of frauds to detect before fail | `3` |
184
+
185
+ #### Face Frontality Features (`face_frontal_features`)
186
+
187
+ | Property | Type | Description | Default |
188
+ |----------|------|-------------|---------|
189
+ | `yaw_threshold` | `number` | Yaw angle threshold in degrees | `3` |
190
+ | `pitch_threshold` | `number` | Pitch angle threshold in degrees | `4` |
191
+ | `roll_threshold` | `number` | Roll angle threshold in degrees | `2` |
192
+
193
+ #### Image Quality Features (`image_quality_features`)
194
+
195
+ | Property | Type | Description | Default |
196
+ |----------|------|-------------|---------|
197
+ | `require_full_face_in_bounds` | `boolean` | Require face completely within bounds | `false` |
198
+ | `use_opencv_enhancement` | `boolean` | Use OpenCV enhancement for quality detection | `true` |
199
+ | `min_laplacian_variance` | `number` | Minimum Laplacian variance for blur detection | `50` |
200
+ | `min_gradient_sharpness` | `number` | Minimum gradient sharpness for blur detection | `0.15` |
201
+ | `min_blur_score` | `number` | Minimum blur score | `0.6` |
202
+
203
+ #### Liveness Detection Settings
204
+
205
+ | Property | Type | Description | Default |
206
+ |----------|------|-------------|---------|
207
+ | `liveness_action_list` | `LivenessAction[]` | List of liveness actions to detect | `[BLINK, MOUTH_OPEN, NOD]` |
208
+ | `liveness_action_count` | `number` | Number of liveness actions to perform | `1` |
209
+ | `liveness_action_randomize` | `boolean` | Randomize liveness actions order | `true` |
210
+ | `liveness_verify_timeout` | `number` | Timeout for liveness verification in ms | `60000` |
211
+ | `min_mouth_open_percent` | `number` | Minimum mouth open percentage (0-1) | `0.2` |
188
212
 
189
- // ========== Liveness Settings ==========
190
- liveness_action_list?: LivenessAction[] // List of liveness actions to detect (default: [BLINK, MOUTH_OPEN, NOD])
191
- liveness_action_count?: number // Number of liveness actions to perform (default: 1)
192
- liveness_action_randomize?: boolean // Whether to randomize liveness actions (default: true)
193
- liveness_verify_timeout?: number // Timeout for liveness verification in ms (default: 60000)
194
- min_mouth_open_percent?: number // Minimum mouth open percentage for detection (default: 0.2)
195
- }
196
- ```
197
213
 
198
214
  ## API Reference
199
215