修改椭圆大小

This commit is contained in:
Tian jianyong 2025-12-28 18:06:22 +08:00
parent a4e8bbfe7c
commit ad38bb61df

View File

@ -80,6 +80,7 @@ class FaceRecognitionSystem:
'quality': 0,
'face_detected': False,
'face_box': None,
'face_box_mirrored': False, # 标记 face_box 是否已翻转
'person_name': None,
'person_role': None,
'similarity': 0,
@ -1709,6 +1710,7 @@ class FaceRecognitionSystem:
self.display_info['face_detected'] = True
self.display_info['face_box'] = face['box']
self.display_info['face_box_mirrored'] = False # 重置翻转标志
# 记录人脸出现时间
if self.face_present_start is None:
@ -1815,8 +1817,8 @@ class FaceRecognitionSystem:
# 镜像翻转:使画面与实际场景一致(在绘制信息之前)
frame = cv2.flip(frame, 1)
# 调整 face_box 坐标以适应镜像翻转
if self.display_info['face_detected'] and self.display_info['face_box']:
# 调整 face_box 坐标以适应镜像翻转(只翻转一次)
if self.display_info['face_detected'] and self.display_info['face_box'] and not self.display_info['face_box_mirrored']:
h_flip, w_flip = frame.shape[:2]
box = self.display_info['face_box']
x_min = int(box['x_min'])
@ -1824,6 +1826,7 @@ class FaceRecognitionSystem:
# 水平翻转坐标
self.display_info['face_box']['x_min'] = w_flip - 1 - x_max
self.display_info['face_box']['x_max'] = w_flip - 1 - x_min
self.display_info['face_box_mirrored'] = True
# 绘制信息
display_frame = self.draw_info_on_frame(frame)
@ -1832,8 +1835,8 @@ class FaceRecognitionSystem:
h, w = display_frame.shape[:2]
center_x = w // 2
center_y = h // 2
# 椭圆参数:中心点、长轴、短轴、旋转角度、起始角度、结束角度
cv2.ellipse(display_frame, (center_x, center_y), (75, 100), 0, 0, 360, (0, 200, 0), 2)
# 椭圆参数:中心点、宽半轴、高半轴、旋转角度、起始角度、结束角度
cv2.ellipse(display_frame, (center_x, center_y), (90, 120), 0, 0, 360, (0, 200, 0), 2)
# 添加提示文字(使用中文支持函数)
guide_text = "请将脸部对准圆圈内"