@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/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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
|