def show_lidar_topview_with_boxes(pc_velo, objects, calib, objects_pred=None):
    """ top_view image"""
    # print('pc_velo shape: ',pc_velo.shape)
    top_view = utils.lidar_to_top(pc_velo)
    top_image = utils.draw_top_image(top_view)
    print("top_image:", top_image.shape)
    # gt

    def bbox3d(obj):
        box3d_pts_2d, box3d_pts_3d = utils.compute_box_3d(obj, calib.P)
        box3d_pts_3d_velo = calib.project_rect_to_velo(box3d_pts_3d)
        return box3d_pts_3d_velo

    boxes3d = [bbox3d(obj) for obj in objects if obj.type != "DontCare"]
    gt = np.array(boxes3d)
    # print("box2d BV:",boxes3d)
    lines = [obj.type for obj in objects if obj.type != "DontCare"]
    top_image = utils.draw_box3d_on_top(
        top_image, gt, text_lables=lines, scores=None, thickness=1, is_gt=True
    )
    # pred
    if objects_pred is not None:
        boxes3d = [bbox3d(obj) for obj in objects_pred if obj.type != "DontCare"]
        gt = np.array(boxes3d)
        lines = [obj.type for obj in objects_pred if obj.type != "DontCare"]
        top_image = utils.draw_box3d_on_top(
            top_image, gt, text_lables=lines, scores=None, thickness=1, is_gt=False
        )

    cv2.imshow("top_image", top_image)
示例#2
0
def show_lidar_topview_with_boxes(pc_velo,
                                  objects,
                                  calib,
                                  objects_pred=None,
                                  track_pred=None):
    """ top_view image"""
    # print('pc_velo shape: ',pc_velo.shape)
    top_view = utils.lidar_to_top(pc_velo)
    top_image = utils.draw_top_image(top_view)
    print("top_image:", top_image.shape)

    # gt

    def bbox3d(obj):
        box3d_pts_2d, box3d_pts_3d = utils.compute_box_3d(obj, calib.P)
        box3d_pts_3d_velo = calib.project_rect_to_velo(box3d_pts_3d)
        return box3d_pts_3d_velo

    boxes3d = [bbox3d(obj) for obj in objects if obj.type != "DontCare"]
    gt = np.array(boxes3d)
    # print("box2d BV:",boxes3d)
    lines = [obj.type for obj in objects if obj.type != "DontCare"]
    top_image = utils.draw_box3d_on_top(top_image,
                                        gt,
                                        text_lables=lines,
                                        scores=None,
                                        thickness=1,
                                        is_gt=True)
    #pred
    if objects_pred is not None:
        boxes3d = [
            bbox3d(obj) for obj in objects_pred if obj.type != "DontCare"
        ]
        gt = np.array(boxes3d)
        lines = [obj.type for obj in objects_pred if obj.type != "DontCare"]

        top_image = utils.draw_box3d_on_top(top_image,
                                            gt,
                                            text_lables=lines,
                                            scores=None,
                                            thickness=1,
                                            is_gt=False)
    #tracking result
    if track_pred is not None:
        boxes3d = [bbox3d(obj) for obj in track_pred if obj.type != "DontCare"]
        gt = np.array(boxes3d)
        lines = [obj.type for obj in track_pred if obj.type != "DontCare"]
        top_image = utils.draw_box3d_on_top(top_image,
                                            gt,
                                            text_lables=lines,
                                            scores=None,
                                            thickness=1,
                                            is_gt=False,
                                            is_track=True)

    #cv2.namedWindow("top_image_bev", cv2.WINDOW_NORMAL)#窗口大小可变,左是窗口名称
    cv2.namedWindow("top_image_bev", cv2.WINDOW_FREERATIO)  #可鼠标调节自适应比例
    #cv2.resizeWindow("top_image_bev", 640, 480)#ly
    cv2.imshow("top_image_bev", top_image)