|
|
@@ -324,13 +324,19 @@ class TextFiller:
|
|
|
h_overlap_ratio = (inter_x2 - inter_x1) / ocr_width if ocr_width > 0 else 0
|
|
|
v_overlap_ratio = (inter_y2 - inter_y1) / ocr_height if ocr_height > 0 else 0
|
|
|
|
|
|
+ # 计算单元格重叠比例(重叠面积 / 单元格面积)
|
|
|
+ cell_area = (cell_x2 - cell_x1) * (cell_y2 - cell_y1)
|
|
|
+ cell_overlap_ratio = inter_area / cell_area if cell_area > 0 else 0
|
|
|
+
|
|
|
# 垂直方向使用更严格的阈值,水平方向使用较宽松的阈值
|
|
|
# 同时检查重叠面积是否超过最小阈值
|
|
|
is_overlapping = (
|
|
|
- (h_overlap_ratio > self.overlap_threshold_horizontal and
|
|
|
- v_overlap_ratio > self.overlap_threshold_vertical) and
|
|
|
+ h_overlap_ratio > 0.1 and # 最小横向重叠保护
|
|
|
+ v_overlap_ratio > self.overlap_threshold_vertical and
|
|
|
+ (h_overlap_ratio > 0.15 or cell_overlap_ratio > 0.4) and # 双重阈值
|
|
|
inter_area >= self.min_overlap_area
|
|
|
)
|
|
|
+
|
|
|
else:
|
|
|
# 使用统一阈值
|
|
|
is_overlapping = overlap_ratio > overlap_threshold
|