@sssxyd/face-liveness-detector 0.4.0-alpha.12 → 0.4.0-alpha.13
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 +49 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -2
- package/dist/index.js.map +1 -1
- package/dist/types/face-detection-engine.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -5338,42 +5338,89 @@ class FaceDetectionEngine extends SimpleEventEmitter {
|
|
|
5338
5338
|
async detect() {
|
|
5339
5339
|
// 防止并发调用
|
|
5340
5340
|
if (this.isDetectingFrameActive) {
|
|
5341
|
+
this.emitDebug('detection', '检测帧正在处理中,跳过本帧', {}, 'info');
|
|
5341
5342
|
return;
|
|
5342
5343
|
}
|
|
5343
5344
|
// 状态和前置条件检查
|
|
5344
|
-
if (this.engineState !== EngineState.DETECTING
|
|
5345
|
+
if (this.engineState !== EngineState.DETECTING) {
|
|
5346
|
+
this.emitDebug('detection', '引擎状态不是DETECTING,无法继续检测', {
|
|
5347
|
+
currentState: this.engineState,
|
|
5348
|
+
expectedState: EngineState.DETECTING
|
|
5349
|
+
}, 'warn');
|
|
5350
|
+
return;
|
|
5351
|
+
}
|
|
5352
|
+
if (!this.videoElement) {
|
|
5353
|
+
this.emitDebug('detection', '视频元素未初始化', {}, 'error');
|
|
5354
|
+
return;
|
|
5355
|
+
}
|
|
5356
|
+
if (!this.human) {
|
|
5357
|
+
this.emitDebug('detection', 'Human.js实例未初始化', {}, 'error');
|
|
5345
5358
|
return;
|
|
5346
5359
|
}
|
|
5347
5360
|
if (this.videoElement.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
5361
|
+
this.emitDebug('detection', '视频尚未准备好,readyState不足', {
|
|
5362
|
+
readyState: this.videoElement.readyState,
|
|
5363
|
+
requiredState: HTMLMediaElement.HAVE_CURRENT_DATA
|
|
5364
|
+
}, 'info');
|
|
5348
5365
|
return;
|
|
5349
5366
|
}
|
|
5350
5367
|
// 设置检测帧活跃标志
|
|
5351
5368
|
this.isDetectingFrameActive = true;
|
|
5352
5369
|
this.frameIndex++;
|
|
5370
|
+
this.emitDebug('detection', '进入检测帧循环', {
|
|
5371
|
+
frameIndex: this.frameIndex,
|
|
5372
|
+
period: this.detectionState.period,
|
|
5373
|
+
engineState: this.engineState,
|
|
5374
|
+
videoReadyState: this.videoElement.readyState
|
|
5375
|
+
}, 'info');
|
|
5353
5376
|
let bgrFrame = null;
|
|
5354
5377
|
let grayFrame = null;
|
|
5355
5378
|
try {
|
|
5356
5379
|
// 确定是否需要捕获帧
|
|
5357
5380
|
if (!this.shouldCaptureFrame()) {
|
|
5381
|
+
this.emitDebug('detection', '不需要捕获本帧', {
|
|
5382
|
+
frameIndex: this.frameIndex,
|
|
5383
|
+
shouldPerformMainDetection: this.shouldPerformMainDetection(),
|
|
5384
|
+
shouldPerformScreenCornersDetection: this.shouldPerformScreenCornersDetection(),
|
|
5385
|
+
shouldPerformScreenFeatureDetection: this.shouldPerformScreenFeatureDetection(),
|
|
5386
|
+
period: this.detectionState.period
|
|
5387
|
+
}, 'info');
|
|
5358
5388
|
return;
|
|
5359
5389
|
}
|
|
5360
|
-
|
|
5390
|
+
this.emitDebug('detection', '准备采集帧数据', { frameIndex: this.frameIndex }, 'info');
|
|
5361
5391
|
const frameData = this.captureAndPrepareFrames();
|
|
5362
5392
|
if (!frameData) {
|
|
5393
|
+
this.emitDebug('detection', '帧采集失败,无法继续检测', {
|
|
5394
|
+
frameIndex: this.frameIndex
|
|
5395
|
+
}, 'warn');
|
|
5363
5396
|
return;
|
|
5364
5397
|
}
|
|
5398
|
+
this.emitDebug('detection', '帧采集成功,准备进行检测', {
|
|
5399
|
+
frameIndex: this.frameIndex,
|
|
5400
|
+
hasBgrFrame: !!frameData.bgrFrame,
|
|
5401
|
+
hasGrayFrame: !!frameData.grayFrame
|
|
5402
|
+
}, 'info');
|
|
5365
5403
|
bgrFrame = frameData.bgrFrame;
|
|
5366
5404
|
grayFrame = frameData.grayFrame;
|
|
5367
5405
|
// 添加到屏幕检测器缓冲
|
|
5368
5406
|
if (this.detectionState.period !== DetectionPeriod.DETECT) {
|
|
5369
5407
|
this.detectionState.screenDetector?.addVideoFrame(grayFrame, bgrFrame);
|
|
5408
|
+
this.emitDebug('detection', '已添加帧数据到屏幕检测器缓冲', {
|
|
5409
|
+
frameIndex: this.frameIndex
|
|
5410
|
+
}, 'info');
|
|
5370
5411
|
}
|
|
5371
5412
|
// 执行屏幕检测(边角 + 多帧特征)
|
|
5413
|
+
this.emitDebug('detection', '开始执行屏幕检测', { frameIndex: this.frameIndex }, 'info');
|
|
5372
5414
|
if (this.performScreenDetection(grayFrame)) {
|
|
5415
|
+
this.emitDebug('detection', '屏幕检测:检测到屏幕,返回', {
|
|
5416
|
+
frameIndex: this.frameIndex
|
|
5417
|
+
}, 'warn');
|
|
5373
5418
|
return;
|
|
5374
5419
|
}
|
|
5375
5420
|
// 执行主人脸检测
|
|
5421
|
+
this.emitDebug('detection', '开始执行人脸检测', { frameIndex: this.frameIndex }, 'info');
|
|
5376
5422
|
await this.performFaceDetection(grayFrame, bgrFrame);
|
|
5423
|
+
this.emitDebug('detection', '人脸检测完成', { frameIndex: this.frameIndex }, 'info');
|
|
5377
5424
|
}
|
|
5378
5425
|
catch (error) {
|
|
5379
5426
|
const errorInfo = this.extractErrorInfo(error);
|