(gt_annos, dt_annos, metric, num_parts=50)
return overlaps, parted_overlaps, total_gt_num, total_dt_num
fast iou algorithm. this function can be used independently to
    do result analysis. Must be used in CAMERA coordinate system.
    Args:
        gt_annos: dict, must from get_label_annos() in kitti_common.py
        dt_annos: dict, must from get_label_annos() in kitti_common.py
        metric: eval type. 0: bbox, 1: bev, 2: 3d
        num_parts: int. a parameter for fast calculate algorithm
fast iou algorithm. this function can be used independently to
    do result analysis. Must be used in CAMERA coordinate system.
    Args:
        gt_annos: dict, must from get_label_annos() in kitti_common.py
        dt_annos: dict, must from get_label_annos() in kitti_common.py
        metric: eval type. 0: bbox, 1: bev, 2: 3d
        num_parts: int. a parameter for fast calculate algorithm
fast iou algorithm . this function can be used independently to do result analysis . Must be used in CAMERA coordinate system . Args : gt_annos : dict must from get_label_annos () in kitti_common . py dt_annos : dict must from get_label_annos () in kitti_common . py metric : eval type . 0 : bbox 1 : bev 2 : 3d num_parts : int . a parameter for fast calculate algorithm
def calculate_iou_partly(gt_annos, dt_annos, metric, num_parts=50):
    """fast iou algorithm. this function can be used independently to
    do result analysis. Must be used in CAMERA coordinate system.
    Args:
        gt_annos: dict, must from get_label_annos() in kitti_common.py
        dt_annos: dict, must from get_label_annos() in kitti_common.py
        metric: eval type. 0: bbox, 1: bev, 2: 3d
        num_parts: int. a parameter for fast calculate algorithm
    """
    assert len(gt_annos) == len(dt_annos)
    total_dt_num = np.stack([len(a["name"]) for a in dt_annos], 0)
    total_gt_num = np.stack([len(a["name"]) for a in gt_annos], 0)
    num_examples = len(gt_annos)
    split_parts = get_split_parts(num_examples, num_parts)
    parted_overlaps = []
    example_idx = 0

    for num_part in split_parts:
        gt_annos_part = gt_annos[example_idx:example_idx + num_part]
        dt_annos_part = dt_annos[example_idx:example_idx + num_part]
        if metric == 0:
            gt_boxes = np.concatenate([a["bbox"] for a in gt_annos_part], 0)
            dt_boxes = np.concatenate([a["bbox"] for a in dt_annos_part], 0)
            overlap_part = image_box_overlap(gt_boxes, dt_boxes)
        elif metric == 1:
            loc = np.concatenate(
                [a["location"][:, [0, 2]] for a in gt_annos_part], 0)
            dims = np.concatenate(
                [a["dimensions"][:, [0, 2]] for a in gt_annos_part], 0)
            rots = np.concatenate([a["rotation_y"] for a in gt_annos_part], 0)
            gt_boxes = np.concatenate(
                [loc, dims, rots[..., np.newaxis]], axis=1)
            loc = np.concatenate(
                [a["location"][:, [0, 2]] for a in dt_annos_part], 0)
            dims = np.concatenate(
                [a["dimensions"][:, [0, 2]] for a in dt_annos_part], 0)
            rots = np.concatenate([a["rotation_y"] for a in dt_annos_part], 0)
            dt_boxes = np.concatenate(
                [loc, dims, rots[..., np.newaxis]], axis=1)
            overlap_part = bev_box_overlap(gt_boxes, dt_boxes).astype(
                np.float64)
        elif metric == 2:
            loc = np.concatenate([a["location"] for a in gt_annos_part], 0)
            dims = np.concatenate([a["dimensions"] for a in gt_annos_part], 0)
            rots = np.concatenate([a["rotation_y"] for a in gt_annos_part], 0)
            gt_boxes = np.concatenate(
                [loc, dims, rots[..., np.newaxis]], axis=1)
            loc = np.concatenate([a["location"] for a in dt_annos_part], 0)
            dims = np.concatenate([a["dimensions"] for a in dt_annos_part], 0)
            rots = np.concatenate([a["rotation_y"] for a in dt_annos_part], 0)
            dt_boxes = np.concatenate(
                [loc, dims, rots[..., np.newaxis]], axis=1)
            overlap_part = d3_box_overlap(gt_boxes, dt_boxes).astype(
                np.float64)
        else:
            raise ValueError("unknown metric")
        parted_overlaps.append(overlap_part)
        example_idx += num_part
    overlaps = []
    example_idx = 0
    for j, num_part in enumerate(split_parts):
        gt_annos_part = gt_annos[example_idx:example_idx + num_part]
        dt_annos_part = dt_annos[example_idx:example_idx + num_part]
        gt_num_idx, dt_num_idx = 0, 0
        for i in range(num_part):
            gt_box_num = total_gt_num[example_idx + i]
            dt_box_num = total_dt_num[example_idx + i]
            overlaps.append(
                parted_overlaps[j][gt_num_idx:gt_num_idx + gt_box_num,
                                   dt_num_idx:dt_num_idx + dt_box_num])
            gt_num_idx += gt_box_num
            dt_num_idx += dt_box_num
        example_idx += num_part

    return overlaps, parted_overlaps, total_gt_num, total_dt_num
def calculate_iou_partly ( gt_annos , dt_annos , metric , num_parts = 50 ) : assert len ( gt_annos ) == len ( dt_annos ) total_dt_num = np . stack ( [ len ( a [ "name" ] ) for a in dt_annos ] , 0 ) total_gt_num = np . stack ( [ len ( a [ "name" ] ) for a in gt_annos ] , 0 ) num_examples = len ( gt_annos ) split_parts = get_split_parts ( num_examples , num_parts ) parted_overlaps = [ ] example_idx = 0 for num_part in split_parts : gt_annos_part = gt_annos [ example_idx : example_idx + num_part ] dt_annos_part = dt_annos [ example_idx : example_idx + num_part ] if metric == 0 : gt_boxes = np . concatenate ( [ a [ "bbox" ] for a in gt_annos_part ] , 0 ) dt_boxes = np . concatenate ( [ a [ "bbox" ] for a in dt_annos_part ] , 0 ) overlap_part = image_box_overlap ( gt_boxes , dt_boxes ) elif metric == 1 : loc = np . concatenate ( [ a [ "location" ] [ : , [ 0 , 2 ] ] for a in gt_annos_part ] , 0 ) dims = np . concatenate ( [ a [ "dimensions" ] [ : , [ 0 , 2 ] ] for a in gt_annos_part ] , 0 ) rots = np . concatenate ( [ a [ "rotation_y" ] for a in gt_annos_part ] , 0 ) gt_boxes = np . concatenate ( [ loc , dims , rots [ ... , np . newaxis ] ] , axis = 1 ) loc = np . concatenate ( [ a [ "location" ] [ : , [ 0 , 2 ] ] for a in dt_annos_part ] , 0 ) dims = np . concatenate ( [ a [ "dimensions" ] [ : , [ 0 , 2 ] ] for a in dt_annos_part ] , 0 ) rots = np . concatenate ( [ a [ "rotation_y" ] for a in dt_annos_part ] , 0 ) dt_boxes = np . concatenate ( [ loc , dims , rots [ ... , np . newaxis ] ] , axis = 1 ) overlap_part = bev_box_overlap ( gt_boxes , dt_boxes ) . astype ( np . float64 ) elif metric == 2 : loc = np . concatenate ( [ a [ "location" ] for a in gt_annos_part ] , 0 ) dims = np . concatenate ( [ a [ "dimensions" ] for a in gt_annos_part ] , 0 ) rots = np . concatenate ( [ a [ "rotation_y" ] for a in gt_annos_part ] , 0 ) gt_boxes = np . concatenate ( [ loc , dims , rots [ ... , np . newaxis ] ] , axis = 1 ) loc = np . concatenate ( [ a [ "location" ] for a in dt_annos_part ] , 0 ) dims = np . concatenate ( [ a [ "dimensions" ] for a in dt_annos_part ] , 0 ) rots = np . concatenate ( [ a [ "rotation_y" ] for a in dt_annos_part ] , 0 ) dt_boxes = np . concatenate ( [ loc , dims , rots [ ... , np . newaxis ] ] , axis = 1 ) overlap_part = d3_box_overlap ( gt_boxes , dt_boxes ) . astype ( np . float64 ) else : raise ValueError ( "unknown metric" ) parted_overlaps . append ( overlap_part ) example_idx += num_part overlaps = [ ] example_idx = 0 for j , num_part in enumerate ( split_parts ) : gt_annos_part = gt_annos [ example_idx : example_idx + num_part ] dt_annos_part = dt_annos [ example_idx : example_idx + num_part ] gt_num_idx , dt_num_idx = 0 , 0 for i in range ( num_part ) : gt_box_num = total_gt_num [ example_idx + i ] dt_box_num = total_dt_num [ example_idx + i ] overlaps . append ( parted_overlaps [ j ] [ gt_num_idx : gt_num_idx + gt_box_num , dt_num_idx : dt_num_idx + dt_box_num ] ) gt_num_idx += gt_box_num dt_num_idx += dt_box_num example_idx += num_part return overlaps , parted_overlaps , total_gt_num , total_dt_num