拉伸人脸识别分辨率

This commit is contained in:
Tian jianyong 2025-12-18 17:10:02 +08:00
parent c70ca9d35c
commit 353543103d

View File

@ -1707,20 +1707,13 @@ class FaceRecognitionSystem:
self.logger.info("开始处理视频流")
# 创建显示窗口并最大化
# 创建显示窗口并设置为全屏
window_name = 'Hello'
cv2.namedWindow(window_name, cv2.WINDOW_NORMAL | cv2.WINDOW_GUI_NORMAL)
cv2.namedWindow(window_name, cv2.WINDOW_NORMAL)
# 设置窗口为全屏或最大化
cv2.setWindowProperty(window_name, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_NORMAL)
try:
import screeninfo
screen = screeninfo.get_monitors()[0]
cv2.resizeWindow(window_name, screen.width, screen.height)
cv2.moveWindow(window_name, 0, 0)
except:
cv2.resizeWindow(window_name, 1920, 1080)
self.logger.warning("无法获取屏幕分辨率,使用默认窗口大小")
# 设置窗口为全屏模式
cv2.setWindowProperty(window_name, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
self.logger.info("人脸识别窗口设置为全屏模式")
# 添加推流健康检查计数器
stream_check_counter = 0
@ -1911,8 +1904,21 @@ class FaceRecognitionSystem:
self.logger.debug("人脸消失,重置计时器")
self.face_present_start = None
# 绘制信息并显示
# 绘制信息
display_frame = self.draw_info_on_frame(frame)
# 获取屏幕尺寸并拉伸视频帧到全屏
try:
import screeninfo
screen = screeninfo.get_monitors()[0]
screen_width, screen_height = screen.width, screen.height
# 拉伸视频帧到屏幕尺寸
display_frame = cv2.resize(display_frame, (screen_width, screen_height), interpolation=cv2.INTER_LINEAR)
except:
# 如果获取屏幕信息失败,使用默认尺寸
display_frame = cv2.resize(display_frame, (1920, 1080), interpolation=cv2.INTER_LINEAR)
cv2.imshow(window_name, display_frame)
# 检查二维码显示是否超时