mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2025-12-29 07:58:41 +00:00
fix
This commit is contained in:
parent
32c65b0dfd
commit
715fc2377e
@ -23,7 +23,6 @@ import string
|
||||
from shapely.geometry import LineString, Point, Polygon
|
||||
import json
|
||||
import copy
|
||||
from scipy.spatial import distance as dist
|
||||
from ppocr.utils.logging import get_logger
|
||||
|
||||
|
||||
@ -70,22 +69,15 @@ class DetLabelEncode(object):
|
||||
return data
|
||||
|
||||
def order_points_clockwise(self, pts):
|
||||
"""
|
||||
refer to :https://github.com/PyImageSearch/imutils/blob/9f740a53bcc2ed7eba2558afed8b4c17fd8a1d4c/imutils/perspective.py#L9
|
||||
"""
|
||||
# sort the points based on their x-coordinates
|
||||
xSorted = pts[np.argsort(pts[:, 0]), :]
|
||||
|
||||
leftMost = xSorted[:2, :]
|
||||
rightMost = xSorted[2:, :]
|
||||
|
||||
leftMost = leftMost[np.argsort(leftMost[:, 1]), :]
|
||||
(tl, bl) = leftMost
|
||||
|
||||
D = dist.cdist(tl[np.newaxis], rightMost, "euclidean")[0]
|
||||
(br, tr) = rightMost[np.argsort(D)[::-1], :]
|
||||
|
||||
return np.array([tl, tr, br, bl], dtype="float32")
|
||||
rect = np.zeros((4, 2), dtype="float32")
|
||||
s = pts.sum(axis=1)
|
||||
rect[0] = pts[np.argmin(s)]
|
||||
rect[2] = pts[np.argmax(s)]
|
||||
tmp = np.delete(pts, (np.argmin(s), np.argmax(s)), axis=0)
|
||||
diff = np.diff(np.array(tmp), axis=1)
|
||||
rect[1] = tmp[np.argmin(diff)]
|
||||
rect[3] = tmp[np.argmax(diff)]
|
||||
return rect
|
||||
|
||||
def expand_points_num(self, boxes):
|
||||
max_points_num = 0
|
||||
|
||||
@ -150,7 +150,7 @@ class TextDetector(object):
|
||||
logger=logger)
|
||||
|
||||
def order_points_clockwise(self, pts):
|
||||
rect = np.zeros((4, 2), dtype="int32")
|
||||
rect = np.zeros((4, 2), dtype="float32")
|
||||
s = pts.sum(axis=1)
|
||||
rect[0] = pts[np.argmin(s)]
|
||||
rect[2] = pts[np.argmax(s)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user