Closed songbae closed 2 years ago
Yes. It can be adopted at the same time. However, the rotation augmentation can not be simply interpreted as just
[ cos@ , -sin@ ,0]
[sin@, cos@ , 0]
[0, 0, 1]
See https://github.com/microsoft/SoftTeacher/blob/5dcbd98cb29acfea6e4da9dd72121c952cb857f4/ssod/datasets/pipelines/rand_aug.py#L488 What it really do is
So the rotation matrix is
alpha=cos@
beta=sin@
center = (w/2,h/2)
rotation_matrix=[alpha, beta, (1 - alpha) * center[0] - beta * center[1]],
[-beta, alpha, beta * center[0] + (1 - alpha) * center[1]],
[0, 0, 1],
Maybe you have referred to https://github.com/microsoft/SoftTeacher/blob/5dcbd98cb29acfea6e4da9dd72121c952cb857f4/ssod/datasets/pipelines/geo_utils.py#L35, but I have to say it is wrong... I am sorry to have forgot to delete it.
Yes. It can be adopted at the same time. However, the rotation augmentation can not be simply interpreted as just
[ cos@ , -sin@ ,0] [sin@, cos@ , 0] [0, 0, 1]
See
What it really do is
- Translate the coordinates to the center of the image
- Rotate the image by selected angle
- Translate the coordinates to the left top of the image.
So the rotation matrix is
alpha=cos@ beta=sin@ center = (w/2,h/2) rotation_matrix=[alpha, beta, (1 - alpha) * center[0] - beta * center[1]], [-beta, alpha, beta * center[0] + (1 - alpha) * center[1]], [0, 0, 1],
Maybe you have referred to
, but I have to say it is wrong... I am sorry to have forgot to delete it.
yeah , i was wondering about that "def _get_rotate_metrix " from the code it's just simply implemented by just
[ cos@ , -sin@ ,0]
[sin@, cos@ , 0]
[0, 0, 1]
so the right trans_matrix be the
M=cv2.cv2.getRotationMatrix2D(center, -angle, self.scale)
M= [alpha, beta, (1 - alpha) * center[0] - beta * center[1]],
[-beta, alpha, beta * center[0] + (1 - alpha) * center[1]]
right?
Yes.
M=cv2.cv2.getRotationMatrix2D(center, -angle, self.scale)
or
M= [alpha, beta, (1 - alpha) * center[0] - beta * center[1]],
[-beta, alpha, beta * center[0] + (1 - alpha) * center[1]]
using geometry augmentations , in repo u have to save the trans_matrix
Q1. in augementation does rotate and shift can be adapted at same time?
if i make this trans_matrix does it mean rotate for @ and shift (x,y) ? it's confusing because when i use cv2.warpAffine
it rotates the img by not center but by left-top .