def rotate_horizontal_bbox_to_oriented(center, bbox):
"""
Step 4 of Figure 5 in seglink paper:
Rotate the cropped horizontal bbox back to its original direction
Args:
center: the center of rotation
bbox: [cx, cy, w, h, theta]
Return: the oriented bbox
"""
assert np.shape(center) == (2, ), "center must be a vector of length 2"
assert np.shape(bbox) == (5, ) , "bbox must be a vector of length 4 or 5"
bbox = np.asarray(bbox.copy(), dtype = np.float32)
cx, cy, w, h, theta = bbox;
M = cv2.getRotationMatrix2D(center, -theta, scale = 1) # 2x3
cx, cy = np.dot(M, np.transpose([cx, cy, 1]))
bbox[0:2] = [cx, cy]
return bbox
评论列表
文章目录