示例#1
0
    def evaluate(self,
                 points_2d,
                 pose_targets,
                 class_type,
                 intri_type='blender',
                 vote_type=VotingType.BB8,
                 intri_matrix=None):
        points_3d = VotingType.get_pts_3d(vote_type, class_type)

        if intri_type == 'use_intrinsic' and intri_matrix is not None:
            K = intri_matrix
        else:
            K = self.projector.intrinsic_matrix[intri_type]

        pose_pred = pnp(points_3d, points_2d, K)
        model = self.linemod_db.get_ply_model(class_type)
        diameter = self.linemod_db.get_diameter(class_type)

        if class_type in ['eggbox', 'glue']:
            self.add_metric_sym(pose_pred, pose_targets, model, diameter)
        else:
            self.add_metric(pose_pred, pose_targets, model, diameter)

        self.projection_2d(pose_pred, pose_targets, model, K)
        self.cm_degree_5_metric(pose_pred, pose_targets)

        return pose_pred
示例#2
0
    def evaluate_uncertainty_v2(self, mean_pts2d, covar, pose_targets, class_type,
                             intri_type='blender', vote_type=VotingType.BB8):
        points_3d = VotingType.get_pts_3d(vote_type, class_type)

        pose_pred = uncertainty_pnp_v2(mean_pts2d, covar, points_3d, self.projector.intrinsic_matrix[intri_type])
        model = self.linemod_db.get_ply_model(class_type)
        diameter = self.linemod_db.get_diameter(class_type)

        if class_type in ['eggbox','glue']:
            self.projection_2d_sym(pose_pred, pose_targets, model, self.projector.intrinsic_matrix[intri_type])
            self.add_metric_sym(pose_pred, pose_targets, model, diameter)
        else:
            self.projection_2d(pose_pred, pose_targets, model, self.projector.intrinsic_matrix[intri_type])
            self.add_metric(pose_pred, pose_targets, model, diameter)
        self.cm_degree_5_metric(pose_pred, pose_targets)
示例#3
0
    def evaluate_uncertainty(self,
                             mean_pts2d,
                             covar,
                             pose_targets,
                             class_type,
                             intri_type='blender',
                             vote_type=VotingType.BB8,
                             intri_matrix=None):
        points_3d = VotingType.get_pts_3d(vote_type, class_type)

        begin = time.time()
        # full
        cov_invs = []
        for vi in range(covar.shape[0]):
            if covar[vi, 0, 0] < 1e-6 or np.sum(np.isnan(covar)[vi]) > 0:
                cov_invs.append(np.zeros([2, 2]).astype(np.float32))
                continue

            cov_inv = np.linalg.inv(scipy.linalg.sqrtm(covar[vi]))
            cov_invs.append(cov_inv)
        cov_invs = np.asarray(cov_invs)  # pn,2,2
        weights = cov_invs.reshape([-1, 4])
        weights = weights[:, (0, 1, 3)]

        if intri_type == 'use_intrinsic' and intri_matrix is not None:
            K = intri_matrix
        else:
            K = self.projector.intrinsic_matrix[intri_type]

        pose_pred = uncertainty_pnp(mean_pts2d, weights, points_3d, K)
        model = self.linemod_db.get_ply_model(class_type)
        diameter = self.linemod_db.get_diameter(class_type)
        self.uncertainty_pnp_cost.append(time.time() - begin)

        if class_type in ['eggbox', 'glue']:
            self.add_metric_sym(pose_pred, pose_targets, model, diameter)
        else:
            self.add_metric(pose_pred, pose_targets, model, diameter)

        self.projection_2d(pose_pred, pose_targets, model, K)
        self.cm_degree_5_metric(pose_pred, pose_targets)

        return pose_pred