fix: restore generic sections and AI analysis in formula report
This commit is contained in:
@ -998,7 +998,9 @@ class WaterQualityReportGenerator:
|
|||||||
# ── 封面 ──
|
# ── 封面 ──
|
||||||
self._add_cover_page(doc)
|
self._add_cover_page(doc)
|
||||||
self._add_company_description_page(doc)
|
self._add_company_description_page(doc)
|
||||||
_next("封面与单位介绍")
|
self._add_data_acquisition_section(doc)
|
||||||
|
self._add_data_processing_section(doc)
|
||||||
|
_next("封面与通用章节")
|
||||||
|
|
||||||
# ── 1. 项目背景 ──
|
# ── 1. 项目背景 ──
|
||||||
h1 = doc.add_heading("1 项目背景", level=1)
|
h1 = doc.add_heading("1 项目背景", level=1)
|
||||||
@ -1477,7 +1479,10 @@ class WaterQualityReportGenerator:
|
|||||||
h3 = doc.add_heading("航线规划:", level=3)
|
h3 = doc.add_heading("航线规划:", level=3)
|
||||||
self._style_heading(h3, level=3)
|
self._style_heading(h3, level=3)
|
||||||
latest = max(flight_map_files, key=lambda p: p.stat().st_mtime)
|
latest = max(flight_map_files, key=lambda p: p.stat().st_mtime)
|
||||||
self._add_image_with_caption(doc, str(latest), "航线规划", width=Inches(5.5))
|
if self._add_image_with_caption(doc, str(latest), "航线规划", width=Inches(5.5)):
|
||||||
|
if self.enable_ai_analysis:
|
||||||
|
self._add_ai_analysis_paragraph(doc,
|
||||||
|
self._analyze_flight_path_image(str(latest)))
|
||||||
|
|
||||||
# 1. 高光谱原始图像
|
# 1. 高光谱原始图像
|
||||||
hsi_path = work_dir_path / "1_water_mask" / "hsi_preview.png"
|
hsi_path = work_dir_path / "1_water_mask" / "hsi_preview.png"
|
||||||
@ -1491,15 +1496,16 @@ class WaterQualityReportGenerator:
|
|||||||
if wm_path.exists():
|
if wm_path.exists():
|
||||||
h3 = doc.add_heading("水体区域识别:", level=3)
|
h3 = doc.add_heading("水体区域识别:", level=3)
|
||||||
self._style_heading(h3, level=3)
|
self._style_heading(h3, level=3)
|
||||||
self._add_image_with_caption(doc, str(wm_path),
|
if self._add_image_with_caption(doc, str(wm_path),
|
||||||
"水体区域识别(蓝色半透明区域为水域)",
|
"水体区域识别(蓝色半透明区域为水域)",
|
||||||
width=Inches(5.5))
|
width=Inches(5.5)):
|
||||||
|
if self.enable_ai_analysis:
|
||||||
|
self._add_ai_analysis_paragraph(doc,
|
||||||
|
self._analyze_water_mask_overlay(str(wm_path)))
|
||||||
|
|
||||||
# 3. 耀斑区域
|
# 3. 耀斑区域
|
||||||
glint_dirs = [
|
glint_dirs = [vis_dir / "glint_deglint_previews",
|
||||||
vis_dir / "glint_deglint_previews",
|
work_dir_path / "2_Glint_Detection"]
|
||||||
work_dir_path / "2_Glint_Detection",
|
|
||||||
]
|
|
||||||
glint_img = None
|
glint_img = None
|
||||||
for d in glint_dirs:
|
for d in glint_dirs:
|
||||||
if d.exists():
|
if d.exists():
|
||||||
@ -1510,7 +1516,10 @@ class WaterQualityReportGenerator:
|
|||||||
if glint_img:
|
if glint_img:
|
||||||
h3 = doc.add_heading("耀斑区域识别结果:", level=3)
|
h3 = doc.add_heading("耀斑区域识别结果:", level=3)
|
||||||
self._style_heading(h3, level=3)
|
self._style_heading(h3, level=3)
|
||||||
self._add_image_with_caption(doc, str(glint_img), "耀斑区域识别结果", width=Inches(5.5))
|
if self._add_image_with_caption(doc, str(glint_img), "耀斑区域识别结果", width=Inches(5.5)):
|
||||||
|
if self.enable_ai_analysis:
|
||||||
|
self._add_ai_analysis_paragraph(doc,
|
||||||
|
self._analyze_glint_distribution_with_ai(str(glint_img)))
|
||||||
|
|
||||||
# 4. 去除耀斑后的图像
|
# 4. 去除耀斑后的图像
|
||||||
deglint_img = None
|
deglint_img = None
|
||||||
@ -1520,7 +1529,6 @@ class WaterQualityReportGenerator:
|
|||||||
if cands:
|
if cands:
|
||||||
deglint_img = cands[0]
|
deglint_img = cands[0]
|
||||||
break
|
break
|
||||||
# 也在 3_deglint 目录搜索
|
|
||||||
deglint_dir2 = work_dir_path / "3_deglint"
|
deglint_dir2 = work_dir_path / "3_deglint"
|
||||||
if deglint_img is None and deglint_dir2.exists():
|
if deglint_img is None and deglint_dir2.exists():
|
||||||
cands = sorted(deglint_dir2.glob("*.png"))
|
cands = sorted(deglint_dir2.glob("*.png"))
|
||||||
@ -1531,27 +1539,21 @@ class WaterQualityReportGenerator:
|
|||||||
self._style_heading(h3, level=3)
|
self._style_heading(h3, level=3)
|
||||||
self._add_image_with_caption(doc, str(deglint_img), "去除耀斑后的影像", width=Inches(5.5))
|
self._add_image_with_caption(doc, str(deglint_img), "去除耀斑后的影像", width=Inches(5.5))
|
||||||
|
|
||||||
# 5. 采样点分布图
|
# 5. 采样点分布图(找不到则整节跳过)
|
||||||
sampling_map_dir = vis_dir / "sampling_maps"
|
sampling_map_dir = vis_dir / "sampling_maps"
|
||||||
h3 = doc.add_heading("采样点分布:", level=3)
|
|
||||||
self._style_heading(h3, level=3)
|
|
||||||
|
|
||||||
# 查找采样点分布图文件
|
|
||||||
sampling_map_files = []
|
sampling_map_files = []
|
||||||
if sampling_map_dir.exists():
|
if sampling_map_dir.exists():
|
||||||
sampling_map_files = list(sampling_map_dir.glob("*.png")) + list(sampling_map_dir.glob("*.jpg"))
|
sampling_map_files = (list(sampling_map_dir.glob("*.png"))
|
||||||
|
+ list(sampling_map_dir.glob("*.jpg")))
|
||||||
|
|
||||||
if sampling_map_files:
|
if sampling_map_files:
|
||||||
# 使用最新的采样点分布图文件
|
h3 = doc.add_heading("采样点分布:", level=3)
|
||||||
|
self._style_heading(h3, level=3)
|
||||||
latest_sampling_map = max(sampling_map_files, key=lambda p: p.stat().st_mtime)
|
latest_sampling_map = max(sampling_map_files, key=lambda p: p.stat().st_mtime)
|
||||||
success = self._add_image_with_caption(doc, str(latest_sampling_map), "采样点分布图", width=Inches(5.5))
|
if self._add_image_with_caption(doc, str(latest_sampling_map), "采样点分布图", width=Inches(5.5)):
|
||||||
|
if self.enable_ai_analysis:
|
||||||
if success:
|
self._add_ai_analysis_paragraph(doc,
|
||||||
# AI 分析采样点分布图
|
self._analyze_sampling_distribution(str(latest_sampling_map)))
|
||||||
sampling_analysis = self._analyze_sampling_distribution(str(latest_sampling_map))
|
|
||||||
self._add_ai_analysis_paragraph(doc, sampling_analysis)
|
|
||||||
else:
|
|
||||||
doc.add_paragraph("[采样点分布图 - 文件未找到]")
|
|
||||||
|
|
||||||
def _analyze_glint_distribution_with_ai(self, glint_img_path: str = None, original_img_path: str = None) -> str:
|
def _analyze_glint_distribution_with_ai(self, glint_img_path: str = None, original_img_path: str = None) -> str:
|
||||||
"""使用AI分析耀斑的位置分布"""
|
"""使用AI分析耀斑的位置分布"""
|
||||||
|
|||||||
Reference in New Issue
Block a user