黑白名单改为0、1

This commit is contained in:
zqc
2025-12-21 15:58:39 +08:00
parent d1509fccc9
commit 9d1dc412e8

View File

@@ -27,7 +27,7 @@ class BaseFaceBiz:
self.app = face_analysis
# 业务参数配置
self.list_mode = "blacklist" # "blacklist" 或 "whitelist"
self.list_mode = "0" # 0 = blacklist, 1= whitelist
self.clarity_threshold = 100.0 # 清晰度阈值,低于此值认为人脸模糊
self.min_face_size = 20 # 最小人脸像素尺寸
self.pitch_threshold = 90 # 俯仰角阈值
@@ -39,11 +39,11 @@ class BaseFaceBiz:
def set_list_mode(self, mode: str):
"""设置名单模式"""
if mode.lower() in ["blacklist", "whitelist"]:
if mode.lower() in ["0", "1"]:
self.list_mode = mode.lower()
print(f"✅ 名单模式设置为: {self.list_mode}")
else:
print("❌ 无效的名单模式,请使用 'blacklist''whitelist'")
print("❌ 无效的名单模式,请使用 '0''1'")
def get_list_mode(self) -> str:
"""获取当前名单模式"""
@@ -307,7 +307,7 @@ class BaseFaceBiz:
best_name, similarity = self.find_best_match(face.embedding)
# 根据名单模式判断是否匹配
if self.list_mode == "blacklist":
if self.list_mode == "0":
# 黑名单模式:在黑名单中即为匹配(需要关注)
is_match = best_name is not None and similarity >= self.similarity_threshold
else: # whitelist
@@ -342,7 +342,7 @@ class BaseFaceBiz:
color = (128, 128, 128) # 灰色 - 质量不可接受
else:
# 选择颜色 - 根据名单模式
if self.list_mode == "blacklist":
if self.list_mode == "0":
# 黑名单模式:匹配(在黑名单中)显示红色,不匹配显示绿色
color = (0, 0, 255) if is_match else (0, 255, 0) # 红色-黑名单, 绿色-正常
else: # whitelist