未验证 提交 3d692957 编写于 作者: M MissPenguin 提交者: GitHub

Merge pull request #5805 from MissPenguin/dygraph

fix order_points_clockwise
...@@ -150,27 +150,13 @@ class TextDetector(object): ...@@ -150,27 +150,13 @@ 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")
reference from: https://github.com/jrosebr1/imutils/blob/master/imutils/perspective.py s = pts.sum(axis=1)
# sort the points based on their x-coordinates rect[0] = pts[np.argmin(s)]
""" rect[2] = pts[np.argmax(s)]
xSorted = pts[np.argsort(pts[:, 0]), :] diff = np.diff(pts, axis=1)
rect[1] = pts[np.argmin(diff)]
# grab the left-most and right-most points from the sorted rect[3] = pts[np.argmax(diff)]
# x-roodinate points
leftMost = xSorted[:2, :]
rightMost = xSorted[2:, :]
# now, sort the left-most coordinates according to their
# y-coordinates so we can grab the top-left and bottom-left
# points, respectively
leftMost = leftMost[np.argsort(leftMost[:, 1]), :]
(tl, bl) = leftMost
rightMost = rightMost[np.argsort(rightMost[:, 1]), :]
(tr, br) = rightMost
rect = np.array([tl, tr, br, bl], dtype="float32")
return rect return rect
def clip_det_res(self, points, img_height, img_width): def clip_det_res(self, points, img_height, img_width):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册