예제 #1
0
def NMS_unique(iou, corners_unique, scores_unique):
    ind_sort = np.argsort([x for x in scores_unique])
    bboxes = []
    score_list = []
    id_list = []
    indice = []
    iou_prov = []
    for i in range(len(corners_unique)):
        bbox = corners_unique[ind_sort[i]]
        flag = 1
        for k in range(i + 1, len(corners_unique)):
            #print("index ", ind_sort[i], scores_unique[ind_sort[i]], "index _comp: ", ind_sort[k],
            #      scores_unique[ind_sort[k]], "IoU: ", provider.box3d_iou(bbox, corners_unique[ind_sort[k]]))
            if provider.box3d_iou(bbox, corners_unique[ind_sort[k]])[1] > 0.25:
                flag = -1
                break
        if flag == 1:
            bboxes.append(bbox)
            indice.append(ind_sort[i])

            iou_prov.append(iou[ind_sort[i]])
            score_list.append(scores_unique[ind_sort[i]])

    for i in range(len(iou_prov) - 1):
        iou_prov[i] = 0.0
    return iou_prov
예제 #2
0
def NMS(id_list_frame, pred_box_frame, IoU_frame, segp_sum_frame,
        score_list_frame, indice_box_frame):
    bboxes_frame = []
    score_new_frame = []
    iou_new_frame = []
    id_new_frame = []
    indices_frame = []

    # estimate corners for all detections in box
    for j in range(len(id_list_frame)):
        # estimate 3DIoU for a box with other boxes for a batch

        #print("len(corners3d)",len(pred_box_frame[j]))
        #print("len(score_list_frame[j])",len(score_list_frame[j]))
        bboxes = []
        score_list = []
        id_list = []
        indice = []
        iou_prov = []

        ind_sort = np.argsort([x * -1.0 for x in score_list_frame[j]])

        #print("ind_sort",ind_sort)
        for i in range(len(pred_box_frame[j])):
            bbox = pred_box_frame[j][ind_sort[i]]
            flag = 1
            for k in range(i + 1, len(pred_box_frame[j])):
                if (np.array_equal(bbox, pred_box_frame[j][ind_sort[k]])):
                    flag = -1
                    break
                #print("index ",ind_sort[i],score_list_frame[j][ind_sort[i]], "index _comp: ", ind_sort[k], score_list_frame[j][ind_sort[k]],"IoU: ",provider.box3d_iou(bbox,pred_box_frame[j][ind_sort[k]]))
                if provider.box3d_iou(bbox,
                                      pred_box_frame[j][ind_sort[k]])[1] > 0.3:
                    flag = -1
                    break
            if flag == 1:
                bboxes.append(bbox)
                id_list.append(id_list_frame[j][ind_sort[i]])
                indice.append(ind_sort[i])
                iou_prov.append(IoU_frame[j][ind_sort[i]])
                score_list.append(score_list_frame[j][ind_sort[i]])

            #print("boxes size:", len(bboxes))
        bboxes_frame.append(bboxes)
        indices_frame.append(indice)
        score_new_frame.append(score_list)
        iou_new_frame.append(iou_prov)
        id_new_frame.append(id_list)

    return bboxes_frame, score_new_frame, id_new_frame, indices_frame, iou_new_frame
예제 #3
0
def compare_box_iou(
    res,
    split,
    id_list,
    indice_box,
    size_residual_GT,
    size_class_GT,
    heading_res_GT,
    heading_class_GT,
    center_GT,
    score_list,
    size_res_list,
    size_cls_list,
    heading_res_list,
    heading_cls_list,
    center_list,
    segp_list,
    seg_list,
):
    file1 = open(OUTPUT_FILE + "/" + split + "_" + res + ".txt", "w")
    IoU = []
    GT_box_list = []
    pred_box_list = []
    for i in range(len(size_residual_GT)):

        GT_box = provider.get_3d_box(
            provider.class2size(size_class_GT[i], size_residual_GT[i]),
            provider.class2angle(heading_class_GT[i], heading_res_GT[i], 12),
            center_GT[i])
        pred_box = provider.get_3d_box(
            provider.class2size(size_cls_list[i], size_res_list[i]),
            provider.class2angle(heading_cls_list[i], heading_res_list[i], 12),
            center_list[i])
        GT_box_list.append(GT_box)
        pred_box_list.append(pred_box)
        iou_3d, iou_2d = provider.box3d_iou(pred_box, GT_box)
        IoU.append(iou_3d)
        file1.write("3D box %f \n" % id_list[i])
        file1.write("iou %f  ,score %f \n " % (float(iou_3d), score_list[i]))
        file1.write("label seg number: %f \n" %
                    np.count_nonzero(seg_list[i] == 1))
        file1.write("det seg number: %f\n" %
                    np.count_nonzero(segp_list[i] == 1))
        #file1.write("correct per seen: %d" %np.sum(seg_list[i] == segp_list[i] )/len(seg_list[i])[0])
        file1.write("center: %f , %f, %f\n" %
                    (center_list[i][0], center_list[i][1], center_list[i][2]))
        file1.write("center_GT: %f , %f , %f\n" %
                    (center_GT[i][0], center_GT[i][1], center_GT[i][2]))
        size_pred = provider.class2size(size_cls_list[i], size_res_list[i])
        file1.write("size pred: %f , %f , %f\n" %
                    (size_pred[0], size_pred[1], size_pred[2]))
        size_GT = provider.class2size(size_class_GT[i], size_residual_GT[i])
        file1.write("size GT: %f, %f , %f\n" %
                    (size_GT[0], size_GT[1], size_GT[2]))
        file1.write(
            "rotation pred %f\n" %
            provider.class2angle(heading_cls_list[i], heading_res_list[i], 12))
        file1.write(
            "rotation GT %f\n" %
            provider.class2angle(heading_class_GT[i], heading_res_GT[i], 12))

    file1.close()
    return IoU, GT_box_list, pred_box_list