提交 d576a61a 编写于 作者: W wangxinxin08

modify @ to be compatible to python2

上级 fca6a9c4
...@@ -482,7 +482,7 @@ def transform_bbox(bbox, ...@@ -482,7 +482,7 @@ def transform_bbox(bbox,
n = len(bbox) n = len(bbox)
xy = np.ones((n * 4, 3), dtype=np.float32) xy = np.ones((n * 4, 3), dtype=np.float32)
xy[:, :2] = bbox[:, [0, 1, 2, 3, 0, 3, 2, 1]].reshape(n * 4, 2) xy[:, :2] = bbox[:, [0, 1, 2, 3, 0, 3, 2, 1]].reshape(n * 4, 2)
xy = xy @ M.T xy = np.matmul(xy, M.T)
if perspective: if perspective:
xy = (xy[:, :2] / xy[:, 2:3]).reshape(n, 8) xy = (xy[:, :2] / xy[:, 2:3]).reshape(n, 8)
else: else:
......
...@@ -2919,7 +2919,10 @@ class RandomPerspective(BaseOperator): ...@@ -2919,7 +2919,10 @@ class RandomPerspective(BaseOperator):
T[1, 2] = random.uniform(0.5 - self.translate, 0.5 + self.translate) * height T[1, 2] = random.uniform(0.5 - self.translate, 0.5 + self.translate) * height
# matmul # matmul
M = T @ S @ R @ P @ C # M = T @ S @ R @ P @ C
M = np.eye(3)
for cM in [T, S, R, P, C]:
M = np.matmul(M, cM)
if (self.border[0] != 0) or (self.border[1] != 0) or (M != np.eye(3)).any(): if (self.border[0] != 0) or (self.border[1] != 0) or (M != np.eye(3)).any():
if self.perspective: if self.perspective:
im = cv2.warpPerspective(im, M, dsize=(width, height), borderValue=self.border_value) im = cv2.warpPerspective(im, M, dsize=(width, height), borderValue=self.border_value)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册