@sssxyd/face-liveness-detector 0.4.1-beta.4 → 0.4.1-beta.5

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 CHANGED
@@ -3962,19 +3962,8 @@ class FaceDetectionEngine extends SimpleEventEmitter {
3962
3962
  this.stopDetection(false);
3963
3963
  return;
3964
3964
  }
3965
- let bgrFrame = null;
3966
- let grayFrame = null;
3967
3965
  try {
3968
- const frameData = this.captureAndPrepareFrames();
3969
- if (!frameData) {
3970
- this.emitDebug('detection', '帧采集失败,无法继续检测', {
3971
- frameIndex: this.frameIndex
3972
- }, 'warn');
3973
- return;
3974
- }
3975
- bgrFrame = frameData.bgrFrame;
3976
- grayFrame = frameData.grayFrame;
3977
- const motionResult = this.detectionState.motionDetector.analyzeMotion(grayFrame, faceBox);
3966
+ const motionResult = this.detectionState.motionDetector.analyzeMotion(face, faceBox);
3978
3967
  // 只有ready状态的检测器的结果才可信
3979
3968
  if (this.detectionState.motionDetector.isReady()) {
3980
3969
  if (!motionResult.isLively) {
@@ -4014,6 +4003,15 @@ class FaceDetectionEngine extends SimpleEventEmitter {
4014
4003
  this.emitDebug('detection', 'Face is too large', { ratio: faceRatio.toFixed(4), minRatio: this.options.collect_min_face_ratio, maxRatio: this.options.collect_max_face_ratio }, 'info');
4015
4004
  return;
4016
4005
  }
4006
+ const frameData = this.captureAndPrepareFrames();
4007
+ if (!frameData) {
4008
+ this.emitDebug('detection', '帧采集失败,无法继续检测', {
4009
+ frameIndex: this.frameIndex
4010
+ }, 'warn');
4011
+ return;
4012
+ }
4013
+ const bgrFrame = frameData.bgrFrame;
4014
+ const grayFrame = frameData.grayFrame;
4017
4015
  let frontal = 1;
4018
4016
  // 计算面部正对度,不达标则跳过当前帧
4019
4017
  if (this.detectionState.needFrontalFace()) {