def render_bb_over_bev(bev_map, labels, configs, vis=False):

    # convert BEV map from tensor to numpy array
    bev_map_cpy = (bev_map.squeeze().permute(1, 2, 0).numpy() * 255).astype(
        np.uint8)
    bev_map_cpy = cv2.resize(bev_map_cpy,
                             (configs.bev_width, configs.bev_height))

    # convert bounding box format format and project into bev
    label_objects = tools.convert_labels_into_objects(labels, configs)
    tools.project_detections_into_bev(bev_map_cpy, label_objects, configs,
                                      [0, 255, 0])

    # display bev map
    if vis == True:
        bev_map_cpy = cv2.rotate(bev_map_cpy, cv2.ROTATE_180)
        cv2.imshow("BEV map", bev_map_cpy)
        cv2.waitKey(0)

    return bev_map_cpy
Exemplo n.º 2
0
            lidar_pcl = load_object_from_file(results_fullpath, data_filename,
                                              'lidar_pcl', cnt_frame)

        ## Compute lidar birds-eye view (bev)
        if 'bev_from_pcl' in exec_list:
            print('computing birds-eye view from lidar pointcloud')
            lidar_bev = pcl.bev_from_pcl(lidar_pcl, configs_det)
        else:
            print('loading birds-eve view from result file')
            lidar_bev = load_object_from_file(results_fullpath, data_filename,
                                              'lidar_bev', cnt_frame)

        ## 3D object detection
        if (configs_det.use_labels_as_objects == True):
            print('using groundtruth labels as objects')
            detections = tools.convert_labels_into_objects(
                frame.laser_labels, configs_det)
        else:
            if 'detect_objects' in exec_list:
                print('detecting objects in lidar pointcloud')
                detections = det.detect_objects(lidar_bev, model_det,
                                                configs_det)
            else:
                print('loading detected objects from result file')
                detections = load_object_from_file(
                    results_fullpath, data_filename, 'detections_' +
                    configs_det.arch + '_' + str(configs_det.conf_thresh),
                    cnt_frame)

        ## Validate object labels
        if 'validate_object_labels' in exec_list:
            print("validating object labels")