色域结果多图保存、更换AI生图服务器接口

This commit is contained in:
xinzhu.yin
2026-05-19 10:06:02 +08:00
parent d7495734a5
commit 405b6047b9
5 changed files with 59 additions and 6 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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)