seglink.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:seglink 作者: dengdan 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号