@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.js CHANGED
@@ -5360,42 +5360,89 @@
5360
5360
  async detect() {
5361
5361
  // 防止并发调用
5362
5362
  if (this.isDetectingFrameActive) {
5363
+ this.emitDebug('detection', '检测帧正在处理中,跳过本帧', {}, 'info');
5363
5364
  return;
5364
5365
  }
5365
5366
  // 状态和前置条件检查
5366
- if (this.engineState !== exports.EngineState.DETECTING || !this.videoElement || !this.human) {
5367
+ if (this.engineState !== exports.EngineState.DETECTING) {
5368
+ this.emitDebug('detection', '引擎状态不是DETECTING,无法继续检测', {
5369
+ currentState: this.engineState,
5370
+ expectedState: exports.EngineState.DETECTING
5371
+ }, 'warn');
5372
+ return;
5373
+ }
5374
+ if (!this.videoElement) {
5375
+ this.emitDebug('detection', '视频元素未初始化', {}, 'error');
5376
+ return;
5377
+ }
5378
+ if (!this.human) {
5379
+ this.emitDebug('detection', 'Human.js实例未初始化', {}, 'error');
5367
5380
  return;
5368
5381
  }
5369
5382
  if (this.videoElement.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
5383
+ this.emitDebug('detection', '视频尚未准备好,readyState不足', {
5384
+ readyState: this.videoElement.readyState,
5385
+ requiredState: HTMLMediaElement.HAVE_CURRENT_DATA
5386
+ }, 'info');
5370
5387
  return;
5371
5388
  }
5372
5389
  // 设置检测帧活跃标志
5373
5390
  this.isDetectingFrameActive = true;
5374
5391
  this.frameIndex++;
5392
+ this.emitDebug('detection', '进入检测帧循环', {
5393
+ frameIndex: this.frameIndex,
5394
+ period: this.detectionState.period,
5395
+ engineState: this.engineState,
5396
+ videoReadyState: this.videoElement.readyState
5397
+ }, 'info');
5375
5398
  let bgrFrame = null;
5376
5399
  let grayFrame = null;
5377
5400
  try {
5378
5401
  // 确定是否需要捕获帧
5379
5402
  if (!this.shouldCaptureFrame()) {
5403
+ this.emitDebug('detection', '不需要捕获本帧', {
5404
+ frameIndex: this.frameIndex,
5405
+ shouldPerformMainDetection: this.shouldPerformMainDetection(),
5406
+ shouldPerformScreenCornersDetection: this.shouldPerformScreenCornersDetection(),
5407
+ shouldPerformScreenFeatureDetection: this.shouldPerformScreenFeatureDetection(),
5408
+ period: this.detectionState.period
5409
+ }, 'info');
5380
5410
  return;
5381
5411
  }
5382
- // 采集和准备帧(BGR + Gray)
5412
+ this.emitDebug('detection', '准备采集帧数据', { frameIndex: this.frameIndex }, 'info');
5383
5413
  const frameData = this.captureAndPrepareFrames();
5384
5414
  if (!frameData) {
5415
+ this.emitDebug('detection', '帧采集失败,无法继续检测', {
5416
+ frameIndex: this.frameIndex
5417
+ }, 'warn');
5385
5418
  return;
5386
5419
  }
5420
+ this.emitDebug('detection', '帧采集成功,准备进行检测', {
5421
+ frameIndex: this.frameIndex,
5422
+ hasBgrFrame: !!frameData.bgrFrame,
5423
+ hasGrayFrame: !!frameData.grayFrame
5424
+ }, 'info');
5387
5425
  bgrFrame = frameData.bgrFrame;
5388
5426
  grayFrame = frameData.grayFrame;
5389
5427
  // 添加到屏幕检测器缓冲
5390
5428
  if (this.detectionState.period !== exports.DetectionPeriod.DETECT) {
5391
5429
  this.detectionState.screenDetector?.addVideoFrame(grayFrame, bgrFrame);
5430
+ this.emitDebug('detection', '已添加帧数据到屏幕检测器缓冲', {
5431
+ frameIndex: this.frameIndex
5432
+ }, 'info');
5392
5433
  }
5393
5434
  // 执行屏幕检测(边角 + 多帧特征)
5435
+ this.emitDebug('detection', '开始执行屏幕检测', { frameIndex: this.frameIndex }, 'info');
5394
5436
  if (this.performScreenDetection(grayFrame)) {
5437
+ this.emitDebug('detection', '屏幕检测:检测到屏幕,返回', {
5438
+ frameIndex: this.frameIndex
5439
+ }, 'warn');
5395
5440
  return;
5396
5441
  }
5397
5442
  // 执行主人脸检测
5443
+ this.emitDebug('detection', '开始执行人脸检测', { frameIndex: this.frameIndex }, 'info');
5398
5444
  await this.performFaceDetection(grayFrame, bgrFrame);
5445
+ this.emitDebug('detection', '人脸检测完成', { frameIndex: this.frameIndex }, 'info');
5399
5446
  }
5400
5447
  catch (error) {
5401
5448
  const errorInfo = this.extractErrorInfo(error);