def rotate_oriented_bbox_to_horizontal(center, bbox):
"""
Step 2 of Figure 5 in seglink paper
Rotate bbox horizontally along a `center` point
Args:
center: the center of rotation
bbox: [cx, cy, w, h, theta]
"""
assert np.shape(center) == (2, ), "center must be a vector of length 2"
assert np.shape(bbox) == (5, ) or np.shape(bbox) == (4, ), "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
评论列表
文章目录