提交 62a9e8df 编写于 作者: L LDOUBLEV

fix

上级 a24e30a7
...@@ -70,22 +70,15 @@ class DetLabelEncode(object): ...@@ -70,22 +70,15 @@ class DetLabelEncode(object):
return data return data
def order_points_clockwise(self, pts): def order_points_clockwise(self, pts):
""" rect = np.zeros((4, 2), dtype="float32")
refer to :https://github.com/PyImageSearch/imutils/blob/9f740a53bcc2ed7eba2558afed8b4c17fd8a1d4c/imutils/perspective.py#L9 s = pts.sum(axis=1)
""" rect[0] = pts[np.argmin(s)]
# sort the points based on their x-coordinates rect[2] = pts[np.argmax(s)]
xSorted = pts[np.argsort(pts[:, 0]), :] tmp = np.delete(pts, (np.argmin(s), np.argmax(s)), axis=0)
diff = np.diff(np.array(tmp), axis=1)
leftMost = xSorted[:2, :] rect[1] = tmp[np.argmin(diff)]
rightMost = xSorted[2:, :] rect[3] = tmp[np.argmax(diff)]
return rect
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")
def expand_points_num(self, boxes): def expand_points_num(self, boxes):
max_points_num = 0 max_points_num = 0
......
...@@ -151,22 +151,15 @@ class TextDetector(object): ...@@ -151,22 +151,15 @@ class TextDetector(object):
logger=logger) logger=logger)
def order_points_clockwise(self, pts): def order_points_clockwise(self, pts):
""" rect = np.zeros((4, 2), dtype="float32")
refer to :https://github.com/PyImageSearch/imutils/blob/9f740a53bcc2ed7eba2558afed8b4c17fd8a1d4c/imutils/perspective.py#L9 s = pts.sum(axis=1)
""" rect[0] = pts[np.argmin(s)]
# sort the points based on their x-coordinates rect[2] = pts[np.argmax(s)]
xSorted = pts[np.argsort(pts[:, 0]), :] tmp = np.delete(pts, (np.argmin(s), np.argmax(s)), axis=0)
diff = np.diff(np.array(tmp), axis=1)
leftMost = xSorted[:2, :] rect[1] = tmp[np.argmin(diff)]
rightMost = xSorted[2:, :] rect[3] = tmp[np.argmax(diff)]
return rect
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")
def clip_det_res(self, points, img_height, img_width): def clip_det_res(self, points, img_height, img_width):
for pno in range(points.shape[0]): for pno in range(points.shape[0]):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册