色域结果多图保存、更换AI生图服务器接口
This commit is contained in:
@@ -2,6 +2,23 @@
|
|||||||
import os
|
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)
|
# (item_key, fig_attr, filename, allowed_test_types_or_None, default_bbox_inches_auto)
|
||||||
IMAGE_SPECS = [
|
IMAGE_SPECS = [
|
||||||
("gamut", "gamut_fig", "色域测试结果.png", None, True),
|
("gamut", "gamut_fig", "色域测试结果.png", None, True),
|
||||||
@@ -16,7 +33,7 @@ IMAGE_SPECS = [
|
|||||||
|
|
||||||
|
|
||||||
def save_result_images(result_dir, current_test_type, selected_items,
|
def save_result_images(result_dir, current_test_type, selected_items,
|
||||||
figure_provider, log):
|
figure_provider, log, app=None):
|
||||||
"""根据测试类型和已选项将各测试图表保存为 PNG。
|
"""根据测试类型和已选项将各测试图表保存为 PNG。
|
||||||
|
|
||||||
figure_provider: callable(attr_name) -> matplotlib Figure 或 None
|
figure_provider: callable(attr_name) -> matplotlib Figure 或 None
|
||||||
@@ -27,6 +44,39 @@ def save_result_images(result_dir, current_test_type, selected_items,
|
|||||||
continue
|
continue
|
||||||
if allowed_types is not None and current_test_type not in allowed_types:
|
if allowed_types is not None and current_test_type not in allowed_types:
|
||||||
continue
|
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)
|
fig = figure_provider(fig_attr)
|
||||||
if fig is None:
|
if fig is None:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ _META_SUFFIX = ".json"
|
|||||||
_SUPPORTED_IMG_EXT = (".png", ".jpg", ".jpeg", ".bmp", ".webp")
|
_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_PATH = "api/v1/pqtest/generate"
|
||||||
API_TIMEOUT = 300.0 # 后端最长 60s,留余量
|
API_TIMEOUT = 300.0 # 后端最长 60s,留余量
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ def get_session_id() -> str:
|
|||||||
|
|
||||||
|
|
||||||
def set_session_id(session_id: str) -> str:
|
def set_session_id(session_id: str) -> str:
|
||||||
"""切换到指定会话。空值会抛错。"""
|
"""切换到指定会话。空值会抛错"""
|
||||||
global _session_id
|
global _session_id
|
||||||
sid = (session_id or "").strip()
|
sid = (session_id or "").strip()
|
||||||
if not sid:
|
if not sid:
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ def create_pantone_baseline_panel(self):
|
|||||||
|
|
||||||
self.pantone_status_var = tk.StringVar(value="未开始")
|
self.pantone_status_var = tk.StringVar(value="未开始")
|
||||||
self.pantone_progress_var = tk.StringVar(value="0 / 0")
|
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 = ttk.LabelFrame(root, text="任务配置", padding=8)
|
||||||
config_row.pack(fill=tk.X)
|
config_row.pack(fill=tk.X)
|
||||||
|
|||||||
@@ -771,6 +771,7 @@ class PQAutomationApp:
|
|||||||
result_dir, current_test_type, selected_items,
|
result_dir, current_test_type, selected_items,
|
||||||
lambda attr: getattr(self, attr, None),
|
lambda attr: getattr(self, attr, None),
|
||||||
log,
|
log,
|
||||||
|
app=self,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2) Excel
|
# 2) Excel
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"current_test_type": "sdr_movie",
|
"current_test_type": "screen_module",
|
||||||
"test_types": {
|
"test_types": {
|
||||||
"screen_module": {
|
"screen_module": {
|
||||||
"name": "屏模组性能测试",
|
"name": "屏模组性能测试",
|
||||||
@@ -18,7 +18,8 @@
|
|||||||
"x_tolerance": 0.003,
|
"x_tolerance": 0.003,
|
||||||
"y_ideal": 0.329,
|
"y_ideal": 0.329,
|
||||||
"y_tolerance": 0.003
|
"y_tolerance": 0.003
|
||||||
}
|
},
|
||||||
|
"gamut_reference": "BT.709"
|
||||||
},
|
},
|
||||||
"sdr_movie": {
|
"sdr_movie": {
|
||||||
"name": "SDR Movie测试",
|
"name": "SDR Movie测试",
|
||||||
|
|||||||
Reference in New Issue
Block a user