Exemplo n.º 1
0
                                e = [1.0] * len(p['vsd_taus'])
                            else:
                                e = pose_error.vsd(
                                    R_e, t_e, R_g, t_g, depth_im, K,
                                    p['vsd_deltas'][dataset], p['vsd_taus'],
                                    p['vsd_normalized_by_diameter'],
                                    models_info[obj_id]['diameter'], ren,
                                    obj_id, 'step')

                        elif p['error_type'] == 'mssd':
                            if not spheres_overlap:
                                e = [float('inf')]
                            else:
                                e = [
                                    pose_error.mssd(R_e, t_e, R_g, t_g,
                                                    models[obj_id]['pts'],
                                                    models_sym[obj_id])
                                ]

                        elif p['error_type'] == 'mspd':
                            e = [
                                pose_error.mspd(R_e, t_e, R_g, t_g, K,
                                                models[obj_id]['pts'],
                                                models_sym[obj_id])
                            ]

                        elif p['error_type'] in ['ad', 'add', 'adi']:
                            if not spheres_overlap:
                                # Infinite error if the bounding spheres do not overlap. With
                                # typically used values of the correctness threshold for the AD
                                # error (e.g. k*diameter, where k = 0.1), such pose estimates
Exemplo n.º 2
0
def evaluate_sequence(renderer, obj_id, Re, te, Rview, tview, K, pts, Rgt, tgt, syms, depth_test, Rs, ts):
    """
    Evaluate target object under all given pose estimates [Re, te]. Values for MSSD, MSPD, VSD and ours are computed.
    """

    # BOP toolkit settings and parameters
    delta, taus, normalized_by_diameter, diameter, r2 = 15, [0.2], True, models_info[obj_id]['diameter'],\
                                                        models_meta[obj_id]['frobenius_scale']
    im_width = 640
    theta_adi, theta_mssd, theta_mspd, theta_vsd = 0.1, 0.2, 20, 0.3
    metric, phi = 'frobenius', 20

    # ground-truth pose in camera space
    Rgt_cam = Rview @ Rgt
    tgt_cam = Rview @ tgt + tview

    Rps = []
    tps = []
    errors = []
    for R, t in zip(Re, te):
        # pose in camera space
        Rcam = Rview @ R
        tcam = Rview @ t + tview

        # reshape estimate for BOP toolkit
        tgt = tgt.reshape(3, 1)
        tgt_cam = tgt_cam.reshape(3, 1)
        t = t.reshape(3, 1)
        tcam = tcam.reshape(3, 1)

        # compute baseline pose-error functions
        mssd = error.mssd(R, t, Rgt, tgt, pts, syms) / diameter
        mspd = error.mspd(Rcam, tcam, Rgt_cam, tgt_cam, K, pts, syms) * (640/im_width)
        vsd = np.mean(error.vsd(Rcam, tcam, Rgt_cam, tgt_cam, depth_test, K, delta, taus,
                                normalized_by_diameter, diameter, renderer, obj_id))

        # ours: match estimate to closest plausible pose
        Rp, tp, dp = plausibility.find_closest(R, t, Rs, ts, metric, pts, syms, r2)

        # matched plausible pose in camera space; reshape for BOP toolkit
        Rp_cam = Rview @ Rp
        tp_cam = (Rview @ tp + tview).reshape(3, 1)
        tp = tp.reshape(3, 1)

        # ours: compute implausibility and physical plausibility error terms
        implausibility = np.clip(dp / phi, 0, 1)

        mssd_pp = mssd + theta_mssd * implausibility
        mspd_pp = mspd + theta_mspd * implausibility
        vsd_pp = vsd + theta_vsd * implausibility

        mssd_op = mssd + error.mssd(R, t, Rp, tp, pts, syms) / diameter
        mspd_op = mspd + error.mspd(Rcam, tcam, Rp_cam, tp_cam, K, pts, syms) * (640/im_width)
        vsd_op = vsd + np.mean(error.vsd(Rcam, tcam, Rp_cam, tp_cam, depth_test, K, delta, taus,
                                         normalized_by_diameter, diameter, renderer, obj_id))

        errors.append([mssd, mspd, vsd, implausibility,
                       mssd_pp, mspd_pp, vsd_pp,
                       mssd_op, mspd_op, vsd_op])
        Rps.append(Rp)
        tps.append(tp)
    return np.array(errors), np.array(Rps).reshape(-1, 3, 3), np.array(tps).reshape(-1, 3)