Browse Source

refactor anchor

Zhang Li 2 years ago
parent
commit
1bfa40842d
1 changed files with 6 additions and 1 deletions
  1. 6 1
      core/direction.py

+ 6 - 1
core/direction.py

@@ -69,6 +69,8 @@ class FrontSideAnchor(OcrAnchor):
             return True
         return False
 
+    def locate_anchor(self, res, is_horizontal) -> int:
+        return super(FrontSideAnchor, self).locate_anchor(res, is_horizontal)
 
 class BackSideAnchor(OcrAnchor):
     def __init__(self, name: str):
@@ -81,6 +83,9 @@ class BackSideAnchor(OcrAnchor):
             return True
         return False
 
+    def locate_anchor(self, res, is_horizontal) -> int:
+        return super(BackSideAnchor, self).locate_anchor(res, is_horizontal)
+
 
 def detect_angle(result, ocr_anchor: OcrAnchor):
     lp = LineParser(result)
@@ -113,7 +118,7 @@ class AngleDetector(object):
             result = self.ocr.ocr(img, cls=True)
             angle = detect_angle(result, ocr_anchor)
             # 旋转90度之后要重新计算角度
-            return (angle - 1 + 4) / 4, result
+            return (angle - 1 + 4) % 4, result
 
     def _detect_back(self, image):
         mask = np.zeros(image.shape, dtype=np.uint8)