コード例 #1
0
    def forward(self, obs_local, valid_points):
        # obs_local: <BxHxWx3>
        # valid_points: <BxHxW>

        self.obs_local = deepcopy(obs_local)
        self.valid_points = valid_points
        self.pose_est = self.loc_net(self.obs_local)

        bs = obs_local.shape[0]
        self.obs_local = self.obs_local.view(bs, -1, 3)
        self.valid_points = self.valid_points.view(bs, -1)

        self.obs_global_est = transform_to_global_AVD(self.pose_est,
                                                      self.obs_local)

        if self.training:
            self.unoccupied_local = sample_unoccupied_point(
                self.obs_local, self.n_samples)
            self.unoccupied_global = transform_to_global_AVD(
                self.pose_est, self.unoccupied_local)

            inputs, self.gt = get_M_net_inputs_labels(self.obs_global_est,
                                                      self.unoccupied_global)
            self.occp_prob = self.occup_net(inputs)
            loss = self.compute_loss()
            return loss
コード例 #2
0
 def __getitem__(self, index):
     pcd = self.point_clouds[index, :, :, :]  # <HxWx3>
     valid_points = self.valid_points[index, :]  #<HxW>
     if self._trans_by_pose is not None:
         pcd = pcd.unsqueeze(0)  # <1XHxWx3>
         pose = self._trans_by_pose[index, :].unsqueeze(0)  # <1x3>
         pcd = utils.transform_to_global_AVD(pose, pcd).squeeze(0)
     return pcd, valid_points
コード例 #3
0
def get_scores(checkpoint_dir):
    saved_json_file = os.path.join(checkpoint_dir, 'opt.json')
    train_opt = utils.load_opt_from_json(saved_json_file)
    name = train_opt['name']
    data_dir = '../../../data/ActiveVisionDataset/' + train_opt[
        'data_dir'].split('/')[-1]
    subsample_rate = train_opt['subsample_rate']
    traj = train_opt['traj']
    print(data_dir)
    # load ground truth poses
    dataset = AVD(data_dir, traj, subsample_rate)
    gt_pose = dataset.gt
    gt_location = gt_pose[:, :3]
    pts = dataset.point_clouds  #.numpy()
    #np.save("local.npy",pts)
    #np.save("pose.npy",gt_pose)
    # load predicted poses
    pred_file = os.path.join(opt.checkpoint_dir, 'pose_est.npy')
    pred_pose = np.load(pred_file)
    pred_location = pred_pose[:, :2] * dataset.depth_scale  # denormalization
    pred_location = add_y_coord_for_evaluation(pred_location)

    #print(gt_pose)
    print(pred_pose)
    ate, aligned_location = utils.compute_ate(pred_location, gt_location)
    print('{}, ate: {}'.format(name, ate))
    gt_pose[:, :3] = gt_pose[:, :3] / dataset.depth_scale
    gt_yaw = np.arccos(
        gt_pose[:, 5] /
        np.sqrt(gt_pose[:, 3] * gt_pose[:, 3] + gt_pose[:, 5] * gt_pose[:, 5]))
    gt_pose_xzth = np.vstack((gt_pose[:, 0], gt_pose[:,
                                                     2], -gt_yaw)).transpose()
    colors = np.array([[0, 1, 1], [0, 0, 0], [0, 0, 1], [1, 0, 1],
                       [0.5, 0.5, 0.5], [0, 0.5, 0], [0, 1, 0], [0.5, 0, 0],
                       [0, 0, 0.5], [0.5, 0.5, 0], [0.5, 0, 0.5], [1, 0, 0],
                       [0.75, 0.75, 0.75], [0, 0.5, 0.5], [1, 1, 1], [1, 1,
                                                                      0]])

    #path_or = '../../../bk_origin/DeepMapping/'
    global_point_cloud_file = os.path.join(opt.checkpoint_dir,
                                           'obs_global_est.npy')
    #global_point_cloud_file_or = os.path.join(path_or,global_point_cloud_file[3:])
    pcds_ours = utils.load_obs_global_est(global_point_cloud_file, colors)
    #pcds_or = utils.load_obs_global_est(global_point_cloud_file_or,colors)
    pts_gt = transform_to_global_AVD(gt_pose_xzth, pts).numpy()
    #pts_or = np.load(global_point_cloud_file_or)
    pts_ours = np.load(global_point_cloud_file)

    pts_gt = pts_gt.reshape((16, -1, 3))

    print(pt_diff(pts_gt, pts_ours))
    print(pt_diff(pts_gt, pts_or))