فهرست منبع

refactor(pdf_coordinate_transform): remove outdated bbox transformation function

- Deleted the old `transform_bbox_for_rotation_pypdfium2_old` function to streamline the codebase.
- This function was redundant and not utilized in the current implementation.
zhch158_admin 2 روز پیش
والد
کامیت
712d004e85
1فایلهای تغییر یافته به همراه0 افزوده شده و 74 حذف شده
  1. 0 74
      ocr_utils/pdf_coordinate_transform.py

+ 0 - 74
ocr_utils/pdf_coordinate_transform.py

@@ -242,77 +242,3 @@ def transform_bbox_for_rotation_pypdfium2(
         max(new_x1, new_x2),
         max(new_y1, new_y2)
     ]
-
-def transform_bbox_for_rotation_pypdfium2_old(
-    bbox: List[float],
-    rotation: int,
-    pdf_width: float,
-    pdf_height: float,
-    scale: float
-) -> List[float]:
-    """
-    pypdfium2引擎的坐标转换(坐标值交换)
-    
-    pypdfium2的pdftext返回的坐标已经过部分处理(已旋转到正确位置),
-    但bbox的(x1,y1)和(x2,y2)的大小关系可能出错,只需交换坐标值即可。
-    
-    Args:
-        bbox: 已旋转的坐标 [x1, y1, x2, y2](但顺序可能错误)
-        rotation: PDF页面rotation (0/90/180/270)
-        pdf_width: PDF页面宽度(原始方向,本函数中未使用)
-        pdf_height: PDF页面高度(原始方向,本函数中未使用)
-        scale: 渲染缩放比例
-        
-    Returns:
-        图像坐标 [x1, y1, x2, y2],已确保 x1<x2, y1<y2
-        
-    变换规则:
-        rotation=0:   (x1,y1,x2,y2) → (x1,y1,x2,y2)     # 不变
-        rotation=90:  (x1,y1,x2,y2) → (x1,y2,x2,y1)     # y坐标交换
-        rotation=180: (x1,y1,x2,y2) → (x1,y2,x2,y1)     # y坐标交换
-        rotation=270: (x1,y1,x2,y2) → (x2,y1,x1,y2)     # x坐标交换
-    """
-    x1, y1, x2, y2 = bbox
-    
-    if rotation == 0:
-        # rotation=0时,直接缩放
-        new_x1 = x1 * scale
-        new_y1 = y1 * scale
-        new_x2 = x2 * scale
-        new_y2 = y2 * scale
-        
-    elif rotation == 90:
-        # 顺时针转90度:交换y坐标
-        new_x1 = x1 * scale
-        new_y1 = y2 * scale
-        new_x2 = x2 * scale
-        new_y2 = y1 * scale
-
-    elif rotation == 180:
-        # 旋转180度:交换y坐标
-        new_x1 = x1 * scale
-        new_y1 = y2 * scale
-        new_x2 = x2 * scale
-        new_y2 = y1 * scale
-        
-    elif rotation == 270:
-        # 顺时针转270度:交换x坐标
-        new_x1 = x2 * scale
-        new_y1 = y1 * scale
-        new_x2 = x1 * scale
-        new_y2 = y2 * scale
-        
-    else:
-        logger.warning(f"Unknown rotation: {rotation}, using default transformation")
-        new_x1 = x1 * scale
-        new_y1 = y1 * scale
-        new_x2 = x2 * scale
-        new_y2 = y2 = y2 * scale
-
-    return [
-        min(new_x1, new_x2),
-        min(new_y1, new_y2),
-        max(new_x1, new_x2),
-        max(new_y1, new_y2)
-    ]
-