Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BloodAxe authored Apr 6, 2019
1 parent 3f8d1ce commit 6de2178
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions albumentations/augmentations/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,20 @@ def shift_scale_rotate(img, angle, scale, dx, dy, interpolation=cv2.INTER_LINEAR


def bbox_shift_scale_rotate(bbox, angle, scale, dx, dy, interpolation, rows, cols, **params):
center = (0.5, 0.5)
height, width = rows, cols
center = (width / 2, height / 2)
matrix = cv2.getRotationMatrix2D(center, angle, scale)
matrix[0, 2] += dx
matrix[1, 2] += dy
matrix[0, 2] += dx * width
matrix[1, 2] += dy * height
x = np.array([bbox[0], bbox[2], bbox[2], bbox[0]])
y = np.array([bbox[1], bbox[1], bbox[3], bbox[3]])
ones = np.ones(shape=(len(x)))
points_ones = np.vstack([x, y, ones]).transpose()
points_ones[:, 0] *= width
points_ones[:, 1] *= height
tr_points = matrix.dot(points_ones.T).T
tr_points[:, 0] /= width
tr_points[:, 1] /= height
return [min(tr_points[:, 0]), min(tr_points[:, 1]), max(tr_points[:, 0]), max(tr_points[:, 1])]


Expand Down

0 comments on commit 6de2178

Please sign in to comment.