feat: 完整中文界面本地化

- 将所有界面文字替换为中文显示
- 窗口标题:烟台蓬莱国际机场低能见度识别软件
- 主标题:烟台蓬莱国际机场低能见度识别软件
- 副标题:灯阵监控系统
- 面板标题:系统状态、LED状态矩阵、统计信息
- 状态信息:帧数、处理时间、帧率、模式切换(正常/雾天)
- 统计信息:总LED数、开启/关闭盏数、运行时间
- 视频相关:实时视频标签、无视频信号提示
- 系统指示:在线状态显示
- 使用PIL库支持中文字体渲染,确保所有中文正常显示

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
sladro 2025-09-25 10:30:52 +08:00
parent a8e0bdcfe2
commit bdcfc708cb
2 changed files with 29 additions and 60 deletions

View File

@ -271,7 +271,7 @@ class YantaiVisionXSystem:
display_frame = self.tech_ui.create_display_frame(vis_frame, detection_result)
# 显示图像
cv2.imshow('YantaiVisionX LED Detection System', display_frame)
cv2.imshow('烟台蓬莱国际机场低能见度识别软件', display_frame)
# 在控制台显示矩阵状态每10帧显示一次
if detection_result.frame_count % 10 == 0:

View File

@ -176,14 +176,8 @@ class TechUI:
self._put_chinese_text(canvas, title, (title_x, title_y), 28, self.colors['accent_cyan'])
# 副标题
subtitle = "YantaiVisionX LED Array Monitoring System"
subtitle_size = cv2.getTextSize(subtitle, self.fonts['subtitle'],
self.font_scales['subtitle'], 1)[0]
subtitle_x = x + (w - subtitle_size[0]) // 2
subtitle_y = y + 60
cv2.putText(canvas, subtitle, (subtitle_x, subtitle_y),
self.fonts['subtitle'], self.font_scales['subtitle'],
self.colors['text_secondary'], 1)
subtitle = "灯阵监控系统"
self._put_chinese_text(canvas, subtitle, (title_x + 150, title_y + 35), 18, self.colors['text_secondary'])
# 时间显示
if system_time is None:
@ -221,21 +215,15 @@ class TechUI:
# 无视频时显示占位符
cv2.rectangle(canvas, (x, y), (x + w, y + h),
self.colors['bg_panel'], -1)
placeholder_text = "NO VIDEO SIGNAL"
text_size = cv2.getTextSize(placeholder_text, self.fonts['normal'],
self.font_scales['normal'], 2)[0]
text_x = x + (w - text_size[0]) // 2
text_y = y + (h + text_size[1]) // 2
cv2.putText(canvas, placeholder_text, (text_x, text_y),
self.fonts['normal'], self.font_scales['normal'],
self.colors['text_secondary'], 2)
placeholder_text = "无视频信号"
text_x = x + w // 2 - 40
text_y = y + h // 2
self._put_chinese_text(canvas, placeholder_text, (text_x, text_y), 18, self.colors['text_secondary'])
# 绘制视频标签
cv2.rectangle(canvas, (x, y - 25), (x + 120, y - 2),
cv2.rectangle(canvas, (x, y - 25), (x + 100, y - 2),
self.colors['bg_panel'], -1)
cv2.putText(canvas, "LIVE VIDEO", (x + 10, y - 8),
self.fonts['small'], self.font_scales['small'],
self.colors['accent_cyan'], 1)
self._put_chinese_text(canvas, "实时视频", (x + 10, y - 22), 14, self.colors['accent_cyan'])
def draw_status_panel(self, canvas: np.ndarray, detection_result):
"""
@ -248,44 +236,37 @@ class TechUI:
x, y, w, h = self.panels['status']
# 绘制面板
self._draw_panel(canvas, "SYSTEM STATUS", x, y, w, h)
self._draw_panel(canvas, "系统状态", x, y, w, h)
# 状态信息
status_y = y + 40
line_height = 25
# 帧计数
frame_text = f"Frame: {detection_result.frame_count}"
cv2.putText(canvas, frame_text, (x + 15, status_y),
self.fonts['mono'], self.font_scales['mono'],
self.colors['text_primary'], 1)
frame_text = f"帧数: {detection_result.frame_count}"
self._put_chinese_text(canvas, frame_text, (x + 15, status_y), 14, self.colors['text_primary'])
# 处理时间
status_y += line_height
processing_time = detection_result.processing_time * 1000
time_text = f"Processing: {processing_time:.1f}ms"
cv2.putText(canvas, time_text, (x + 15, status_y),
self.fonts['mono'], self.font_scales['mono'],
self.colors['text_primary'], 1)
time_text = f"处理时间: {processing_time:.1f}毫秒"
self._put_chinese_text(canvas, time_text, (x + 15, status_y), 14, self.colors['text_primary'])
# FPS计算
status_y += line_height
fps = 1.0 / detection_result.processing_time if detection_result.processing_time > 0 else 0
fps_text = f"FPS: {fps:.1f}"
cv2.putText(canvas, fps_text, (x + 15, status_y),
self.fonts['mono'], self.font_scales['mono'],
self.colors['text_primary'], 1)
fps_text = f"帧率: {fps:.1f}FPS"
self._put_chinese_text(canvas, fps_text, (x + 15, status_y), 14, self.colors['text_primary'])
# 检测模式
status_y += line_height
detection_mode = getattr(detection_result, 'detection_mode', 'normal')
mode_text = f"Mode: {detection_mode.upper()}"
cv2.putText(canvas, mode_text, (x + 15, status_y),
self.fonts['mono'], self.font_scales['mono'],
self.colors['accent_cyan'], 1)
mode_name = "正常" if detection_mode == "normal" else "雾天"
mode_text = f"模式: {mode_name}"
self._put_chinese_text(canvas, mode_text, (x + 15, status_y), 14, self.colors['accent_cyan'])
# 系统状态指示灯
self._draw_status_indicator(canvas, x + w - 60, y + 30, "ONLINE", True)
self._draw_status_indicator(canvas, x + w - 80, y + 30, "在线", True)
def draw_led_matrix_panel(self, canvas: np.ndarray, led_states: List[List[bool]]):
"""
@ -298,7 +279,7 @@ class TechUI:
x, y, w, h = self.panels['led_matrix']
# 绘制面板
self._draw_panel(canvas, "LED STATUS MATRIX", x, y, w, h)
self._draw_panel(canvas, "LED状态矩阵", x, y, w, h)
# LED矩阵绘制
matrix_start_x = x + 20
@ -343,7 +324,7 @@ class TechUI:
x, y, w, h = self.panels['stats']
# 绘制面板
self._draw_panel(canvas, "STATISTICS", x, y, w, h)
self._draw_panel(canvas, "统计信息", x, y, w, h)
# 统计信息
stats_y = y + 40
@ -360,26 +341,18 @@ class TechUI:
total_on = total_off = total_leds = 0
# LED统计
cv2.putText(canvas, f"Total LEDs: {total_leds}", (x + 15, stats_y),
self.fonts['mono'], self.font_scales['mono'],
self.colors['text_primary'], 1)
self._put_chinese_text(canvas, f"总LED数: {total_leds}", (x + 15, stats_y), 14, self.colors['text_primary'])
stats_y += line_height
cv2.putText(canvas, f"LEDs ON: {total_on}", (x + 15, stats_y),
self.fonts['mono'], self.font_scales['mono'],
self.colors['success'], 1)
self._put_chinese_text(canvas, f"开启: {total_on}", (x + 15, stats_y), 14, self.colors['success'])
stats_y += line_height
cv2.putText(canvas, f"LEDs OFF: {total_off}", (x + 15, stats_y),
self.fonts['mono'], self.font_scales['mono'],
self.colors['led_off'], 1)
self._put_chinese_text(canvas, f"关闭: {total_off}", (x + 15, stats_y), 14, self.colors['led_off'])
# 运行时间
stats_y += line_height + 5
runtime_text = f"Runtime: {datetime.now().strftime('%H:%M:%S')}"
cv2.putText(canvas, runtime_text, (x + 15, stats_y),
self.fonts['mono'], self.font_scales['mono'],
self.colors['text_secondary'], 1)
runtime_text = f"运行时间: {datetime.now().strftime('%H:%M:%S')}"
self._put_chinese_text(canvas, runtime_text, (x + 15, stats_y), 14, self.colors['text_secondary'])
def _draw_panel(self, canvas: np.ndarray, title: str, x: int, y: int, w: int, h: int):
"""
@ -396,9 +369,7 @@ class TechUI:
# 标题栏
cv2.rectangle(canvas, (x, y), (x + w, y + 30), self.colors['accent_blue'], -1)
cv2.putText(canvas, title, (x + 10, y + 20),
self.fonts['subtitle'], self.font_scales['small'],
self.colors['text_primary'], 1)
self._put_chinese_text(canvas, title, (x + 10, y + 5), 16, self.colors['text_primary'])
# 装饰线
cv2.line(canvas, (x + 5, y + 32), (x + w - 5, y + 32),
@ -421,9 +392,7 @@ class TechUI:
cv2.circle(canvas, (x, y), 6, self.colors['border'], 1)
# 状态文本
cv2.putText(canvas, text, (x + 15, y + 5),
self.fonts['small'], self.font_scales['small'],
color, 1)
self._put_chinese_text(canvas, text, (x + 15, y - 5), 12, color)
def create_display_frame(self, video_frame: np.ndarray, detection_result) -> np.ndarray:
"""