|
|
@@ -299,6 +299,25 @@ class EnhancedDocPipeline:
|
|
|
if removed_count > 0:
|
|
|
logger.info(f"🔄 Page {page_idx}: removed {removed_count} overlapping boxes")
|
|
|
|
|
|
+ # 2.6 将大面积文本块转换为表格(后处理)
|
|
|
+ if layout_results:
|
|
|
+ convert_large_text = self.config.get('layout', {}).get('convert_large_text_to_table', True)
|
|
|
+ if convert_large_text:
|
|
|
+ # 获取图像尺寸 (height, width)
|
|
|
+ img_shape = detection_image.shape
|
|
|
+ if len(img_shape) >= 2:
|
|
|
+ image_shape = (int(img_shape[0]), int(img_shape[1]))
|
|
|
+ else:
|
|
|
+ image_shape = (0, 0)
|
|
|
+
|
|
|
+ layout_results = LayoutUtils.convert_large_text_to_table(
|
|
|
+ layout_results,
|
|
|
+ image_shape,
|
|
|
+ min_area_ratio=self.config.get('layout', {}).get('min_text_area_ratio', 0.25),
|
|
|
+ min_width_ratio=self.config.get('layout', {}).get('min_text_width_ratio', 0.4),
|
|
|
+ min_height_ratio=self.config.get('layout', {}).get('min_text_height_ratio', 0.3)
|
|
|
+ )
|
|
|
+
|
|
|
page_result['layout_raw'] = layout_results
|
|
|
|
|
|
# 3. 整页 OCR 获取所有 text spans(关键改进)
|