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