Zeusee-Face-Anti-spoofing
Zeusee-Face-Anti-spoofing copied to clipboard
关于ActiveDetector_Shake::getState() 代码的一些问题
感谢分享,在AliveDetector.h
的ActiveDetector_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;
}
-
为什么frames[i]<-8时,sum需要--;
-
为什么最后if判断时需要判断“abs(sum-0)<6”;