diff --git a/ppdet/data/transform/op_helper.py b/ppdet/data/transform/op_helper.py index 6919ece50cc9a89baf849704fe037265c7416fe4..b692d294b6d0118779a83867d59a2d04b849892d 100644 --- a/ppdet/data/transform/op_helper.py +++ b/ppdet/data/transform/op_helper.py @@ -482,7 +482,7 @@ def transform_bbox(bbox, n = len(bbox) 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 = xy @ M.T + xy = np.matmul(xy, M.T) if perspective: xy = (xy[:, :2] / xy[:, 2:3]).reshape(n, 8) else: diff --git a/ppdet/data/transform/operators.py b/ppdet/data/transform/operators.py index dcb0aac4180de86b44f5e4fd31070eff1a0954c1..b4c7694fad8e8f618c7adb43addad35cf92a768b 100644 --- a/ppdet/data/transform/operators.py +++ b/ppdet/data/transform/operators.py @@ -2919,7 +2919,10 @@ class RandomPerspective(BaseOperator): T[1, 2] = random.uniform(0.5 - self.translate, 0.5 + self.translate) * height # 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.perspective: im = cv2.warpPerspective(im, M, dsize=(width, height), borderValue=self.border_value)