#!/usr/bin/env python3 """ 测试科技感UI界面 """ import cv2 import numpy as np import sys import os from pathlib import Path # 添加项目根目录到Python路径 project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) from src.ui.tech_ui import TechUI class MockDetectionResult: """模拟检测结果""" def __init__(self): self.frame_count = 1234 self.processing_time = 0.045 self.detection_mode = "normal" self.detection_summary = { 'threshold_detection': { 'states': { 'on': 12, 'off': 6 } } } self.roi_detections = {} # 生成模拟的LED状态 for row in range(1, 4): for col in range(1, 7): roi_name = f"R{row}C{col}" is_on = (row * col) % 3 == 0 # 模拟一些LED开启 self.roi_detections[roi_name] = { 'threshold_detection': { 'is_on': is_on } } def main(): """测试UI界面""" print("测试科技感UI界面...") # 创建UI实例 ui = TechUI() # 创建模拟视频帧 video_frame = np.random.randint(0, 255, (480, 640, 3), dtype=np.uint8) # 在视频帧上添加一些模拟的LED点 for i in range(3): for j in range(6): x = 80 + j * 80 y = 120 + i * 80 color = (0, 255, 0) if (i * j) % 3 == 0 else (100, 100, 100) cv2.circle(video_frame, (x, y), 15, color, -1) cv2.putText(video_frame, f"R{i+1}C{j+1}", (x-15, y+30), cv2.FONT_HERSHEY_SIMPLEX, 0.4, (255, 255, 255), 1) # 创建模拟检测结果 detection_result = MockDetectionResult() # 生成显示帧 display_frame = ui.create_display_frame(video_frame, detection_result) print("按任意键退出...") cv2.imshow('烟台蓬莱国际机场低能见度识别软件', display_frame) cv2.waitKey(0) cv2.destroyAllWindows() print("UI测试完成!") if __name__ == "__main__": main()