Zeusee-Face-Anti-spoofing icon indicating copy to clipboard operation
Zeusee-Face-Anti-spoofing copied to clipboard

关于ActiveDetector_Shake::getState() 代码的一些问题

Open YanFuHai06 opened this issue 4 years ago • 0 comments

感谢分享,在AliveDetector.hActiveDetector_Shake类中getState()方法有一些不理解。

bool getState() {
      if (idx < CYCLE_ACTIVE)
            return false;
        int sum = 0;
        bool flag = 0;
        for (int i = 0; i < CYCLE_ACTIVE; i++) {
            if (frames[i] > 11 || frames[i] < -11) {
                flag = 1;
            }
            if (frames[i] > 8)
                sum++;
            else if (frames[i] < -8)
                sum--;
        }
        if (abs(sum - 0) < 6 && flag == 1)
            return true;
        else
            return false;
    }
  1. 为什么frames[i]<-8时,sum需要--;

  2. 为什么最后if判断时需要判断“abs(sum-0)<6”;

YanFuHai06 avatar Sep 22 '20 13:09 YanFuHai06