Beispiel #1
0
def boxes_iou_bev_gpu(boxes_a,
                      boxes_b,
                      box_mode='wlh',
                      metric='rotate_iou',
                      rect=False):
    """
    This rotate boxes_iou_bev_gpu is about 9.25x faster than box_np_ops.riou_cc.
    The box_np_ops.iou_jit is about 4.1x faster than the nearest boxes_iou_bev_gpu.
    :param boxes_a: (M, 7), [x, y, z, h, w, l, ry], torch tensor with type float32
    :param boxes_b: (N, 7), [x, y, z, h, w, l, ry], torch tensor with type float32
    :return:
        ans_iou: (M, N)
    """
    if metric == 'rotate_iou':
        boxes_a_bev = utils.boxes3d_to_bev_torch(boxes_a, box_mode, rect)
        boxes_b_bev = utils.boxes3d_to_bev_torch(boxes_b, box_mode, rect)
    elif metric == 'nearest_iou':
        boxes_a_bev = utils.rbbox2d_to_near_bbox_torch(boxes_a, box_mode,
                                                       rect).cuda()
        boxes_b_bev = utils.rbbox2d_to_near_bbox_torch(boxes_b, box_mode,
                                                       rect).cuda()
    else:
        raise NotImplementedError

    ans_iou = torch.cuda.FloatTensor(
        torch.Size((boxes_a.shape[0], boxes_b.shape[0]))).zero_()
    iou3d_cuda.boxes_iou_bev_gpu(boxes_a_bev.contiguous(),
                                 boxes_b_bev.contiguous(), ans_iou)
    return ans_iou
Beispiel #2
0
    def boxes_iou_bev(self,boxes_a, boxes_b):
        """
        :param boxes_a: (M, 5)
        :param boxes_b: (N, 5)
        :return:
            ans_iou: (M, N)
        """
        ans_iou = torch.cuda.FloatTensor(torch.Size((boxes_a.shape[0], boxes_b.shape[0]))).zero_()

        iou3d_cuda.boxes_iou_bev_gpu(boxes_a.contiguous(), boxes_b.contiguous(), ans_iou)

        return ans_iou
Beispiel #3
0
def boxes_iou_bev(boxes_a, boxes_b):
    """
    :param boxes_a: (M, 5)
    :param boxes_b: (N, 5)
    :return:
        ans_iou: (M, N)
    """
    if boxes_a.numel() == 0 or boxes_b.numel() == 0:
        return torch.empty((1, 1))
    ans_iou = torch.cuda.FloatTensor(
        torch.Size((boxes_a.shape[0], boxes_b.shape[0]))).zero_()

    iou3d_cuda.boxes_iou_bev_gpu(boxes_a.contiguous(), boxes_b.contiguous(),
                                 ans_iou)

    return ans_iou