|
@@ -335,7 +335,7 @@ class MinerUWiredTableRecognizer:
|
|
|
# Step 2: 使用连通域法提取单元格 (替换了原来的投影法)
|
|
# Step 2: 使用连通域法提取单元格 (替换了原来的投影法)
|
|
|
debug_prefix = f"{dbg.prefix}_grid" if dbg.prefix else "grid"
|
|
debug_prefix = f"{dbg.prefix}_grid" if dbg.prefix else "grid"
|
|
|
|
|
|
|
|
- # 传入原图的实际尺寸和裁剪padding用于计算坐标缩放比例和边缘过滤
|
|
|
|
|
|
|
+ # 传入原图的实际尺寸、裁剪padding和OCR结果
|
|
|
bboxes = self.grid_recovery.compute_cells_from_lines(
|
|
bboxes = self.grid_recovery.compute_cells_from_lines(
|
|
|
hpred_up,
|
|
hpred_up,
|
|
|
vpred_up,
|
|
vpred_up,
|
|
@@ -344,7 +344,9 @@ class MinerUWiredTableRecognizer:
|
|
|
orig_w=w,
|
|
orig_w=w,
|
|
|
debug_dir=debug_dir,
|
|
debug_dir=debug_dir,
|
|
|
debug_prefix=debug_prefix,
|
|
debug_prefix=debug_prefix,
|
|
|
- crop_padding=10 # 传递 padding 值(与 element_processors.py 中的 crop_padding 保持一致)
|
|
|
|
|
|
|
+ crop_padding=10, # 传递 padding 值(与 element_processors.py 中的 crop_padding 保持一致)
|
|
|
|
|
+ ocr_bboxes=ocr_boxes, # 🆕 传递OCR结果用于边缘补偿
|
|
|
|
|
+ enable_ocr_edge_compensation=True # 🆕 启用OCR边缘补偿
|
|
|
)
|
|
)
|
|
|
# bboxes = self.grid_recovery.compute_cells_from_lines(hpred_up, vpred_up, upscale) # Original call
|
|
# bboxes = self.grid_recovery.compute_cells_from_lines(hpred_up, vpred_up, upscale) # Original call
|
|
|
if not bboxes:
|
|
if not bboxes:
|
|
@@ -363,11 +365,8 @@ class MinerUWiredTableRecognizer:
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
# Step 3: 重建网格结构 (计算 row, col, rowspan, colspan)
|
|
# Step 3: 重建网格结构 (计算 row, col, rowspan, colspan)
|
|
|
- # 传入 OCR boxes 以启用 OCR 辅助合并
|
|
|
|
|
- merged_cells = self.grid_recovery.recover_grid_structure(
|
|
|
|
|
- bboxes,
|
|
|
|
|
- ocr_bboxes=ocr_boxes,
|
|
|
|
|
- enable_ocr_compensation=True)
|
|
|
|
|
|
|
+ # OCR补偿已在Step 2中完成,这里仅做网格重建
|
|
|
|
|
+ merged_cells = self.grid_recovery.recover_grid_structure(bboxes)
|
|
|
|
|
|
|
|
# Step 3.5: 可视化逻辑结构 (新增)
|
|
# Step 3.5: 可视化逻辑结构 (新增)
|
|
|
if self.debug_utils.debug_is_on("save_grid_structure", dbg):
|
|
if self.debug_utils.debug_is_on("save_grid_structure", dbg):
|