コード例 #1
0
ファイル: show_gt.py プロジェクト: liuyujiahb/avod
def draw_gt(gt_objects, prop_2d_axes, prop_3d_axes, p_matrix):
    # Draw filtered ground truth boxes
    for obj in gt_objects:
        # Draw 2D boxes
        vis_utils.draw_box_2d(prop_2d_axes, obj, test_mode=True, color_tm='r')

        # Draw 3D boxes
        vis_utils.draw_box_3d(prop_3d_axes, obj, p_matrix,
                              show_orientation=False,
                              color_table=['r', 'y', 'r', 'w'],
                              line_width=2,
                              double_line=False)
コード例 #2
0
def draw_proposals(filtered_gt_objs, p_matrix, num_of_proposals, proposal_objs,
                   proposal_boxes, prop_2d_axes, prop_3d_axes,
                   draw_orientations_on_prop):
    # Draw filtered ground truth boxes
    for obj in filtered_gt_objs:
        # Draw 2D boxes
        vis_utils.draw_box_2d(prop_2d_axes,
                              obj,
                              test_mode=True,
                              color_tm='r',
                              linewidth=linewidth)

        # Draw 3D boxes
        vis_utils.draw_box_3d(prop_3d_axes,
                              obj,
                              p_matrix,
                              show_orientation=draw_orientations_on_prop,
                              color_table=['r', 'y', 'r', 'w'],
                              line_width=line_width,
                              double_line=False)

    # Overlay proposal boxes on images
    for anchor_idx in range(num_of_proposals):
        obj_label = proposal_objs[anchor_idx]

        # Draw 2D boxes (can't use obj_label since 2D corners are not
        # filled in)
        rgb_box_2d = proposal_boxes[anchor_idx]

        box_x1 = rgb_box_2d[0]
        box_y1 = rgb_box_2d[1]
        box_w = rgb_box_2d[2] - box_x1
        box_h = rgb_box_2d[3] - box_y1

        rect = patches.Rectangle((box_x1, box_y1),
                                 box_w,
                                 box_h,
                                 linewidth=line_width,
                                 edgecolor='cornflowerblue',
                                 facecolor='none')

        prop_2d_axes.add_patch(rect)

        # Draw 3D boxes
        vis_utils.draw_box_3d(prop_3d_axes,
                              obj_label,
                              p_matrix,
                              show_orientation=draw_orientations_on_prop,
                              color_table=['cornflowerblue', 'y', 'r', 'w'],
                              line_width=line_width,
                              double_line=False)
コード例 #3
0
ファイル: kitti.py プロジェクト: Fredrik00/wavedata
def main():
    # Start of the Kitti demo code
    print('=== Python Kitti Wrapper Demo ===')

    # Setting Paths
    data_set = 'training'
    cam = 2

    root_dir = '/notebooks/DATA/Kitti/object/'  #os.path.expanduser('~') + '/Kitti/object/'

    image_dir = os.path.join(root_dir, data_set) + '/image_' + str(cam)
    label_dir = os.path.join(root_dir, data_set) + '/label_' + str(cam)
    calib_dir = os.path.join(root_dir, data_set) + '/calib'

    img_idx = int(random.random() * 100)
    print('img_idx', img_idx)

    # Run Visualization Function
    f, ax1, ax2 = vis_utils.visualization(image_dir, img_idx)

    # Run the main loop to run throughout the images
    frame_calibration_info = calib_utils.read_calibration(calib_dir, img_idx)

    p = frame_calibration_info.p2

    # Load labels
    objects = obj_utils.read_labels(label_dir, img_idx)

    # For all annotated objects
    for obj in objects:

        # Draw 2D and 3D boxes
        vis_utils.draw_box_2d(ax1, obj)
        vis_utils.draw_box_3d(ax2, obj, p)

    # Render results
    plt.draw()
    plt.show()
コード例 #4
0
def draw_predictions(filtered_gt_objs, p_matrix, predictions_to_show,
                     prediction_objs, prediction_class, final_boxes,
                     pred_2d_axes, pred_3d_axes, draw_score, draw_iou,
                     gt_classes, draw_orientations_on_pred):
    # Draw filtered ground truth boxes
    gt_boxes = []
    for obj in filtered_gt_objs:
        # Draw 2D boxes
        vis_utils.draw_box_2d(pred_2d_axes, obj, test_mode=True, color_tm='r')

        # Draw 3D boxes
        vis_utils.draw_box_3d(pred_3d_axes,
                              obj,
                              p_matrix,
                              show_orientation=draw_orientations_on_pred,
                              color_table=['r', 'y', 'r', 'w'],
                              line_width=2,
                              double_line=False)
        if draw_iou:
            gt_box_2d = [obj.x1, obj.y1, obj.x2, obj.y2]
            gt_boxes.append(gt_box_2d)

    if gt_boxes:
        # the two_2 eval function expects np.array
        gt_boxes = np.asarray(gt_boxes)

    for pred_idx in range(predictions_to_show):
        pred_obj = prediction_objs[pred_idx]
        pred_class_idx = prediction_class[pred_idx]

        rgb_box_2d = final_boxes[pred_idx]

        box_x1 = rgb_box_2d[0]
        box_y1 = rgb_box_2d[1]
        box_w = rgb_box_2d[2] - box_x1
        box_h = rgb_box_2d[3] - box_y1

        box_cls = gt_classes[int(pred_class_idx)]
        rect = patches.Rectangle((box_x1, box_y1),
                                 box_w,
                                 box_h,
                                 linewidth=2,
                                 edgecolor=BOX_COLOUR_SCHEME[box_cls],
                                 facecolor='none')

        pred_2d_axes.add_patch(rect)

        # Draw 3D boxes
        vis_utils.draw_box_3d(pred_3d_axes,
                              pred_obj,
                              p_matrix,
                              show_orientation=draw_orientations_on_pred,
                              color_table=['#00FF00', 'y', 'r', 'w'],
                              line_width=2,
                              double_line=False,
                              box_color=BOX_COLOUR_SCHEME[box_cls])

        if draw_score or draw_iou:
            box_x2 = rgb_box_2d[2]
            box_y2 = rgb_box_2d[3]

            pred_box_2d = [box_x1, box_y1, box_x2, box_y2]

            info_text_x = (box_x1 + box_x2) / 2
            info_text_y = box_y1

            draw_prediction_info(pred_2d_axes, info_text_x, info_text_y,
                                 pred_obj, pred_class_idx, pred_box_2d,
                                 gt_boxes, draw_score, draw_iou, gt_classes)