增加引导框,调整人脸框的位置
This commit is contained in:
parent
ca83a326fd
commit
fd5aedb3f9
@ -41,11 +41,11 @@ camera:
|
||||
face_detection:
|
||||
frame_interval: 10 # 检测帧间隔(每N帧检测一次)
|
||||
quality_threshold: 10 # 图像质量阈值(Laplacian方差)
|
||||
min_face_size: 80 # 最小人脸尺寸(像素)
|
||||
min_face_size: 60 # 最小人脸尺寸(像素),越小检测距离越远
|
||||
face_present_duration: 2.0 # 持续出现时长(秒)才触发识别
|
||||
max_yaw: 20.0 # 最大允许的偏航角(度),超过此角度视为侧脸
|
||||
max_pitch: 20.0 # 最大允许的俯仰角(度),超过此角度视为抬头或低头
|
||||
no_face_threshold: 30 # 人脸消失计数器阈值(帧),连续N帧没有检测到人脸才清空
|
||||
no_face_threshold: 60 # 人脸消失计数器阈值(帧),约2秒没有检测到人脸才清空
|
||||
|
||||
# 人脸识别配置
|
||||
face_recognition:
|
||||
|
||||
21
face_rec.py
21
face_rec.py
@ -1815,9 +1815,30 @@ class FaceRecognitionSystem:
|
||||
# 镜像翻转:使画面与实际场景一致(在绘制信息之前)
|
||||
frame = cv2.flip(frame, 1)
|
||||
|
||||
# 调整人脸框坐标以适应镜像翻转
|
||||
if self.display_info['face_box']:
|
||||
h, w = frame.shape[:2]
|
||||
box = self.display_info['face_box']
|
||||
x_min = int(box['x_min'])
|
||||
x_max = int(box['x_max'])
|
||||
# 水平翻转坐标:new_x = width - 1 - old_x
|
||||
self.display_info['face_box']['x_min'] = w - 1 - x_max
|
||||
self.display_info['face_box']['x_max'] = w - 1 - x_min
|
||||
|
||||
# 绘制信息
|
||||
display_frame = self.draw_info_on_frame(frame)
|
||||
|
||||
# 绘制人脸轮廓引导框(屏幕中央)
|
||||
h, w = display_frame.shape[:2]
|
||||
center_x = w // 2
|
||||
center_y = h // 2
|
||||
# 椭圆参数:中心点、长轴、短轴、旋转角度、起始角度、结束角度
|
||||
cv2.ellipse(display_frame, (center_x, center_y), (120, 160), 0, 0, 360, (0, 200, 0), 2)
|
||||
|
||||
# 添加提示文字
|
||||
cv2.putText(display_frame, "请将脸部对准圆圈内", (center_x - 100, center_y + 200),
|
||||
cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 200, 0), 2)
|
||||
|
||||
# 使用缓存的屏幕尺寸拉伸视频帧到全屏
|
||||
display_frame = cv2.resize(display_frame, (self.screen_width, self.screen_height), interpolation=cv2.INTER_LINEAR)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user