@sssxyd/face-liveness-detector 0.4.0-alpha.13 → 0.4.0-alpha.15
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/dist/index.esm.js +29 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +29 -23
- package/dist/index.js.map +1 -1
- package/dist/types/face-detection-engine.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2429,7 +2429,7 @@ class MotionLivenessDetector {
|
|
|
2429
2429
|
* 分析失败时创建空结果
|
|
2430
2430
|
*/
|
|
2431
2431
|
createEmptyResult() {
|
|
2432
|
-
return new MotionDetectionResult(0, 0, 0, 0, 0, 'none',
|
|
2432
|
+
return new MotionDetectionResult(0, 0, 0, 0, 0, 'none', true, {
|
|
2433
2433
|
frameCount: this.frameBuffer.length,
|
|
2434
2434
|
avgKeypointDistance: 0,
|
|
2435
2435
|
maxKeypointDistance: 0,
|
|
@@ -5127,6 +5127,7 @@ class FaceDetectionEngine extends SimpleEventEmitter {
|
|
|
5127
5127
|
if (this.engineState === EngineState.DETECTING) {
|
|
5128
5128
|
this.transitionEngineState(EngineState.READY, 'stopDetection()');
|
|
5129
5129
|
}
|
|
5130
|
+
this.cancelPendingDetection();
|
|
5130
5131
|
const finishData = {
|
|
5131
5132
|
success: success,
|
|
5132
5133
|
silentPassedCount: this.detectionState.collectCount,
|
|
@@ -5137,7 +5138,6 @@ class FaceDetectionEngine extends SimpleEventEmitter {
|
|
|
5137
5138
|
bestFaceImage: this.detectionState.bestFaceImage
|
|
5138
5139
|
};
|
|
5139
5140
|
this.emit('detector-finish', finishData);
|
|
5140
|
-
this.cancelPendingDetection();
|
|
5141
5141
|
this.fullResetDetectionState();
|
|
5142
5142
|
if (this.stream) {
|
|
5143
5143
|
this.stream.getTracks().forEach(track => track.stop());
|
|
@@ -5436,6 +5436,12 @@ class FaceDetectionEngine extends SimpleEventEmitter {
|
|
|
5436
5436
|
this.cleanupFrames(bgrFrame, grayFrame);
|
|
5437
5437
|
// 清除检测帧活跃标志
|
|
5438
5438
|
this.isDetectingFrameActive = false;
|
|
5439
|
+
// 调度下一帧的检测
|
|
5440
|
+
if (this.engineState === EngineState.DETECTING) {
|
|
5441
|
+
this.animationFrameId = requestAnimationFrame(() => {
|
|
5442
|
+
this.detect();
|
|
5443
|
+
});
|
|
5444
|
+
}
|
|
5439
5445
|
}
|
|
5440
5446
|
}
|
|
5441
5447
|
/**
|
|
@@ -5721,28 +5727,28 @@ class FaceDetectionEngine extends SimpleEventEmitter {
|
|
|
5721
5727
|
try {
|
|
5722
5728
|
// 运动检测
|
|
5723
5729
|
const motionResult = this.detectionState.motionDetector.analyzeMotion(grayFrame, face, faceBox);
|
|
5724
|
-
|
|
5725
|
-
this.emitDebug('motion-detection', 'Motion liveness check failed - possible photo attack', {
|
|
5726
|
-
motionScore: motionResult.motionScore,
|
|
5727
|
-
keypointVariance: motionResult.keypointVariance,
|
|
5728
|
-
opticalFlowMagnitude: motionResult.opticalFlowMagnitude,
|
|
5729
|
-
eyeMotionScore: motionResult.eyeMotionScore,
|
|
5730
|
-
mouthMotionScore: motionResult.mouthMotionScore,
|
|
5731
|
-
motionType: motionResult.motionType,
|
|
5732
|
-
details: motionResult.details
|
|
5733
|
-
}, 'warn');
|
|
5734
|
-
this.emitDetectorInfo({
|
|
5735
|
-
code: DetectionCode.FACE_NOT_LIVE,
|
|
5736
|
-
message: motionResult.getMessage(this.detectionState.motionDetector.getOptions().minMotionThreshold, this.detectionState.motionDetector.getOptions().minKeypointVariance),
|
|
5737
|
-
motionScore: motionResult.motionScore,
|
|
5738
|
-
keypointVariance: motionResult.keypointVariance,
|
|
5739
|
-
motionType: motionResult.motionType
|
|
5740
|
-
});
|
|
5741
|
-
this.partialResetDetectionState();
|
|
5742
|
-
return;
|
|
5743
|
-
}
|
|
5744
|
-
// 只有ready状态的检测器的success结果才可信
|
|
5730
|
+
// 只有ready状态的检测器的结果才可信
|
|
5745
5731
|
if (this.detectionState.motionDetector.isReady()) {
|
|
5732
|
+
if (!motionResult.isLively) {
|
|
5733
|
+
this.emitDebug('motion-detection', 'Motion liveness check failed - possible photo attack', {
|
|
5734
|
+
motionScore: motionResult.motionScore,
|
|
5735
|
+
keypointVariance: motionResult.keypointVariance,
|
|
5736
|
+
opticalFlowMagnitude: motionResult.opticalFlowMagnitude,
|
|
5737
|
+
eyeMotionScore: motionResult.eyeMotionScore,
|
|
5738
|
+
mouthMotionScore: motionResult.mouthMotionScore,
|
|
5739
|
+
motionType: motionResult.motionType,
|
|
5740
|
+
details: motionResult.details
|
|
5741
|
+
}, 'warn');
|
|
5742
|
+
this.emitDetectorInfo({
|
|
5743
|
+
code: DetectionCode.FACE_NOT_LIVE,
|
|
5744
|
+
message: motionResult.getMessage(this.detectionState.motionDetector.getOptions().minMotionThreshold, this.detectionState.motionDetector.getOptions().minKeypointVariance),
|
|
5745
|
+
motionScore: motionResult.motionScore,
|
|
5746
|
+
keypointVariance: motionResult.keypointVariance,
|
|
5747
|
+
motionType: motionResult.motionType
|
|
5748
|
+
});
|
|
5749
|
+
this.partialResetDetectionState();
|
|
5750
|
+
return;
|
|
5751
|
+
}
|
|
5746
5752
|
this.detectionState.liveness = true;
|
|
5747
5753
|
}
|
|
5748
5754
|
// 计算面部大小比例,不达标则跳过当前帧
|