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