Przeglądaj źródła

fix: 修正图像旋转方法参数名称和逻辑,确保正确处理旋转角度

zhch158_admin 2 tygodni temu
rodzic
commit
b7ddaa6c92

+ 6 - 6
zhch/universal_doc_parser/models/adapters/base.py

@@ -30,15 +30,15 @@ class BasePreprocessor(BaseAdapter):
         """
         pass
     
-    def _apply_rotation(self, image: np.ndarray, rotation_label: int) -> np.ndarray:
+    def _apply_rotation(self, image: np.ndarray, rotation_angle: int) -> np.ndarray:
         """应用旋转"""
         import cv2
-        if rotation_label == 1:  # 90度
-            return cv2.rotate(image, cv2.ROTATE_90_CLOCKWISE)
-        elif rotation_label == 2:  # 180度
-            return cv2.rotate(image, cv2.ROTATE_180)
-        elif rotation_label == 3:  # 270度
+        if rotation_angle == 90:  # 90度
             return cv2.rotate(image, cv2.ROTATE_90_COUNTERCLOCKWISE)
+        elif rotation_angle == 180:  # 180度
+            return cv2.rotate(image, cv2.ROTATE_180)
+        elif rotation_angle == 270:  # 270度
+            return cv2.rotate(image, cv2.ROTATE_90_CLOCKWISE)
         return image
 
 class BaseLayoutDetector(BaseAdapter):