Пример #1
0
def test_rigid_no_noise():

    # Generate some synthetic data.
    n_frames = 40
    n_basis = 1
    n_points = 20

    # Take a randomly generated model.
    gt_model = model.generate_synthetic_model(n_frames, n_basis, n_points)

    # Force scale factor to 1.
    gt_model.C = np.ones((n_frames, 1))

    W = gt_model.W

    # Recover the model
    inf_model = rigid.factor(W)

    # Register with ground truth.
    inf_model.register(gt_model)

    delta = util.norm(inf_model.Ps - gt_model.Ps, axis=1)

    # Ensure the average error is low.
    npt.assert_allclose(delta.mean(), 0, atol=1e-10)
Пример #2
0
def test_recover_Gk_no_noise():

    # Generate some synthetic data.
    n_frames = 30
    n_basis = 2
    n_points = 15
    gt_model = model.generate_synthetic_model(n_frames, n_basis, n_points)

    # Factor the matrix.
    from rigid import factor_matrix
    W = gt_model.W.copy()
    W -= W.mean(axis=-1)[:, np.newaxis]
    M_hat, B_hat = factor_matrix(W, J=n_basis * 3)

    # Try to find a G_k
    G_k = shape.find_G_k(M_hat)

    # Get the k'th column triple of M_k
    M_k = np.dot(M_hat, G_k)
    M_kx = M_k[0::2]
    M_ky = M_k[1::2]

    # Ensure they are orthogonal.
    npt.assert_allclose((M_kx * M_ky).sum(), 0, atol=1e-3)

    # And that the length of x and y are equal.
    npt.assert_allclose((M_kx * M_kx).sum() - (M_ky * M_ky).sum(),
                        0,
                        atol=1e-3)
Пример #3
0
def test_shape_no_noise():

    np.random.seed(100)

    # Generate some synthetic data.
    n_frames = 50
    n_basis = 2
    n_points = 15
    gt_model = model.generate_synthetic_model(n_frames, n_basis, n_points)

    W = gt_model.W

    # Recover the model
    inf_model = shape.factor(W, n_basis=n_basis)

    # Register with ground truth.
    inf_model.register(gt_model)

    delta = util.norm(inf_model.Ps - gt_model.Ps, axis=1)

    # Ensure the average error is low.
    npt.assert_allclose(delta.mean(), 0, atol=0.1)