添加调试日志

This commit is contained in:
Tian jianyong 2025-12-18 14:39:29 +08:00
parent a6f91fed23
commit 66cdcab42c
2 changed files with 10 additions and 19 deletions

View File

@ -42,8 +42,8 @@ face_detection:
quality_threshold: 10 # 图像质量阈值(Laplacian方差)
min_face_size: 80 # 最小人脸尺寸(像素)
face_present_duration: 2.0 # 持续出现时长(秒)才触发识别
max_yaw: 30.0 # 最大允许的偏航角(度),超过此角度视为侧脸
max_pitch: 30.0 # 最大允许的俯仰角(度),超过此角度视为抬头或低头
max_yaw: 60.0 # 最大允许的偏航角(度),超过此角度视为侧脸
max_pitch: 60.0 # 最大允许的俯仰角(度),超过此角度视为抬头或低头
# 人脸识别配置
face_recognition:
@ -58,7 +58,7 @@ role_mapping:
# 日志配置
logging:
level: "INFO" # DEBUG, INFO, WARNING, ERROR
level: "DEBUG" # DEBUG, INFO, WARNING, ERROR
file: "face_recognition.log"
max_bytes: 10485760 # 10MB
backup_count: 5

View File

@ -1245,11 +1245,8 @@ class FaceRecognitionSystem:
# 将帧编码为JPEG
_, img_encoded = cv2.imencode('.jpg', frame)
# 调用CompreFace检测API启用pose插件
result = self.detection_service.detect(
img_encoded.tobytes(),
face_plugins="pose"
)
# 调用CompreFace检测API
result = self.detection_service.detect(img_encoded.tobytes())
if result and 'result' in result and len(result['result']) > 0:
faces = result['result']
@ -1268,17 +1265,11 @@ class FaceRecognitionSystem:
face_height = face['box']['y_max'] - face['box']['y_min']
if face_width >= min_size and face_height >= min_size:
# 检查人脸角度
pose = face.get('pose', {})
yaw = pose.get('yaw', 0.0)
pitch = pose.get('pitch', 0.0)
# 判断是否为正脸
if abs(yaw) <= max_yaw and abs(pitch) <= max_pitch:
valid_faces.append(face)
self.logger.debug(f"人脸角度检查通过: yaw={yaw:.1f}°, pitch={pitch:.1f}°")
else:
self.logger.debug(f"人脸角度超出范围,跳过: yaw={yaw:.1f}°(阈值±{max_yaw}°), pitch={pitch:.1f}°(阈值±{max_pitch}°)")
# 临时记录face数据查看是否有pose信息
self.logger.debug(f"检测到人脸数据: {list(face.keys())}")
if 'pose' in face:
self.logger.debug(f"Pose数据: {face['pose']}")
valid_faces.append(face)
if valid_faces:
# 返回第一个(最大的)人脸