From 405b6047b9eebd9c45ef5322c050536835f4a149 Mon Sep 17 00:00:00 2001 From: "xinzhu.yin" Date: Tue, 19 May 2026 10:06:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=89=B2=E5=9F=9F=E7=BB=93=E6=9E=9C=E5=A4=9A?= =?UTF-8?q?=E5=9B=BE=E4=BF=9D=E5=AD=98=E3=80=81=E6=9B=B4=E6=8D=A2AI?= =?UTF-8?q?=E7=94=9F=E5=9B=BE=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/export/image_exporter.py | 52 +++++++++++++++++++++- app/services/ai_image.py | 5 ++- app/views/panels/pantone_baseline_panel.py | 2 +- pqAutomationApp.py | 1 + settings/pq_config.json | 5 ++- 5 files changed, 59 insertions(+), 6 deletions(-) diff --git a/app/export/image_exporter.py b/app/export/image_exporter.py index 9d5ec7d..f45eb6c 100644 --- a/app/export/image_exporter.py +++ b/app/export/image_exporter.py @@ -2,6 +2,23 @@ import os +def _gamut_refs_for_type(test_type): + """按测试类型返回需要导出的参考色域列表。""" + if test_type == "sdr_movie": + return ["BT.709", "DCI-P3", "BT.2020", "BT.601"] + return ["BT.709", "DCI-P3", "BT.2020"] + + +def _gamut_ref_var_attr(test_type): + if test_type == "screen_module": + return "screen_gamut_ref_var" + if test_type == "sdr_movie": + return "sdr_gamut_ref_var" + if test_type == "hdr_movie": + return "hdr_gamut_ref_var" + return None + + # (item_key, fig_attr, filename, allowed_test_types_or_None, default_bbox_inches_auto) IMAGE_SPECS = [ ("gamut", "gamut_fig", "色域测试结果.png", None, True), @@ -16,7 +33,7 @@ IMAGE_SPECS = [ def save_result_images(result_dir, current_test_type, selected_items, - figure_provider, log): + figure_provider, log, app=None): """根据测试类型和已选项将各测试图表保存为 PNG。 figure_provider: callable(attr_name) -> matplotlib Figure 或 None @@ -27,6 +44,39 @@ def save_result_images(result_dir, current_test_type, selected_items, continue if allowed_types is not None and current_test_type not in allowed_types: continue + + # 色域图:按所有可切换参考状态逐个重绘并保存。 + if item_key == "gamut" and app is not None: + var_attr = _gamut_ref_var_attr(current_test_type) + ref_var = getattr(app, var_attr, None) if var_attr else None + rgb_data = None + coverage = 0.0 + + if hasattr(app, "results") and app.results: + rgb_data = app.results.get_intermediate_data("gamut", "rgb") + try: + coverage = app.results.test_items["gamut"].final_result.get("coverage", 0.0) + except Exception: + coverage = 0.0 + + if ref_var is not None and rgb_data and len(rgb_data) >= 3 and hasattr(app, "plot_gamut"): + original_ref = ref_var.get() + try: + for ref in _gamut_refs_for_type(current_test_type): + ref_var.set(ref) + app.plot_gamut(rgb_data, coverage, current_test_type) + fig = figure_provider(fig_attr) + if fig is None: + continue + per_ref_name = f"色域测试结果_{ref}.png" + path = os.path.join(result_dir, per_ref_name) + fig.savefig(path, dpi=300) + log(f"已保存: {per_ref_name}") + finally: + ref_var.set(original_ref) + app.plot_gamut(rgb_data, coverage, current_test_type) + continue + fig = figure_provider(fig_attr) if fig is None: continue diff --git a/app/services/ai_image.py b/app/services/ai_image.py index b74e042..089c5b5 100644 --- a/app/services/ai_image.py +++ b/app/services/ai_image.py @@ -40,7 +40,8 @@ _META_SUFFIX = ".json" _SUPPORTED_IMG_EXT = (".png", ".jpg", ".jpeg", ".bmp", ".webp") # 测试环境后端 -API_BASE_URL = "http://10.201.44.70:9018/ai-agent/" +# API_BASE_URL = "http://10.201.44.70:9018/ai-agent/" +API_BASE_URL = "https://rd-mokadisplay.tcl.com/ai-agent/" API_PATH = "api/v1/pqtest/generate" API_TIMEOUT = 300.0 # 后端最长 60s,留余量 @@ -55,7 +56,7 @@ def get_session_id() -> str: def set_session_id(session_id: str) -> str: - """切换到指定会话。空值会抛错。""" + """切换到指定会话。空值会抛错""" global _session_id sid = (session_id or "").strip() if not sid: diff --git a/app/views/panels/pantone_baseline_panel.py b/app/views/panels/pantone_baseline_panel.py index bcb831e..d0ad59e 100644 --- a/app/views/panels/pantone_baseline_panel.py +++ b/app/views/panels/pantone_baseline_panel.py @@ -42,7 +42,7 @@ def create_pantone_baseline_panel(self): self.pantone_status_var = tk.StringVar(value="未开始") self.pantone_progress_var = tk.StringVar(value="0 / 0") - self.pantone_settle_var = tk.StringVar(value="0.35") + self.pantone_settle_var = tk.StringVar(value="0.3") config_row = ttk.LabelFrame(root, text="任务配置", padding=8) config_row.pack(fill=tk.X) diff --git a/pqAutomationApp.py b/pqAutomationApp.py index d1edc32..2119190 100644 --- a/pqAutomationApp.py +++ b/pqAutomationApp.py @@ -771,6 +771,7 @@ class PQAutomationApp: result_dir, current_test_type, selected_items, lambda attr: getattr(self, attr, None), log, + app=self, ) # 2) Excel diff --git a/settings/pq_config.json b/settings/pq_config.json index 24ca29a..684ffb3 100644 --- a/settings/pq_config.json +++ b/settings/pq_config.json @@ -1,5 +1,5 @@ { - "current_test_type": "sdr_movie", + "current_test_type": "screen_module", "test_types": { "screen_module": { "name": "屏模组性能测试", @@ -18,7 +18,8 @@ "x_tolerance": 0.003, "y_ideal": 0.329, "y_tolerance": 0.003 - } + }, + "gamut_reference": "BT.709" }, "sdr_movie": { "name": "SDR Movie测试",