Пример #1
0
def test_affine():
    X = loadPoints(Path("tests/fixtures/ref.txt"))
    Y = loadPoints(Path("tests/fixtures/deg.txt"))
    expected = loadXform(Path("tests/fixtures/affine.pickle"))

    P, xform = last(islice(driftAffine(X, Y, w=0.5), 100))

    np.testing.assert_almost_equal(xform.B, expected.B)
    np.testing.assert_almost_equal(xform.t, expected.t)
Пример #2
0
def test_affine():
    X = loadPoints(Path("tests/fixtures/ref.txt"))
    Y = loadPoints(Path("tests/fixtures/deg.txt"))
    expected = loadXform(Path("tests/fixtures/affine.pickle"))

    P, xform = last(islice(driftAffine(X, Y, w=0.5), 100))

    np.testing.assert_almost_equal(xform.B, expected.B)
    np.testing.assert_almost_equal(xform.t, expected.t)
Пример #3
0
def test_global():
    X = loadPoints(Path("tests/fixtures/ref.txt"))
    Y = loadPoints(Path("tests/fixtures/deg.txt"))
    expected = loadXform(Path("tests/fixtures/xform.pickle"))

    P, xform = globalAlignment(X, Y, w=0.5, mirror=True)

    np.testing.assert_almost_equal(xform.R, expected.R)
    np.testing.assert_almost_equal(xform.t, expected.t)
    np.testing.assert_almost_equal(xform.s, expected.s)
Пример #4
0
def test_global():
    X = loadPoints(Path("tests/fixtures/ref.txt"))
    Y = loadPoints(Path("tests/fixtures/deg.txt"))
    expected = loadXform(Path("tests/fixtures/xform.pickle"))

    P, xform = globalAlignment(X, Y, w=0.5, mirror=True)

    np.testing.assert_almost_equal(xform.R, expected.R)
    np.testing.assert_almost_equal(xform.t, expected.t)
    np.testing.assert_almost_equal(xform.s, expected.s)
Пример #5
0
def test_perfect_rigid():
    X = loadPoints(Path("tests/fixtures/ref.txt"))
    P, xform = last(islice(driftRigid(X, X), 100))

    np.testing.assert_almost_equal(xform.R, np.eye(2))
    np.testing.assert_almost_equal(xform.t, np.zeros(2))
    np.testing.assert_almost_equal(xform.s, 1)
Пример #6
0
def test_perfect_rigid():
    X = loadPoints(Path("tests/fixtures/ref.txt"))
    P, xform = last(islice(driftRigid(X, X), 100))

    np.testing.assert_almost_equal(xform.R, np.eye(2))
    np.testing.assert_almost_equal(xform.t, np.zeros(2))
    np.testing.assert_almost_equal(xform.s, 1)
Пример #7
0
def test_xform_inverse(tmpdir):
    expected = loadPoints(Path("tests/fixtures/ref.txt"))

    # Generate degraded points (without noise)
    args = split(
        "xform tests/fixtures/ref.txt tests/fixtures/xform.pickle --format txt"
    )
    r = run(cmd + args, stdout=PIPE, universal_newlines=False)
    assert not r.returncode
    deg = tmpdir.join("deg.txt")
    deg.write_binary(r.stdout)

    # Generate alignment
    args = split("align tests/fixtures/ref.txt '{}' "
                 "--format pickle --scope global".format(str(deg)))
    r = run(cmd + args, stdout=PIPE, universal_newlines=False)
    assert not r.returncode
    xform = tmpdir.join("xform.pickle")
    xform.write_binary(r.stdout)

    # Check alignment xform
    args = split("xform '{}' '{}' --format pickle".format(
        str(deg), str(xform)))
    r = run(cmd + args, stdout=PIPE, universal_newlines=False)
    assert not r.returncode
    result = loads(r.stdout)
    assert_almost_equal(expected, result)
Пример #8
0
def test_print(tmpdir):
    expected = loadPoints(Path("tests/fixtures/ref.txt"))

    # Generate degraded points (without noise)
    args = split("xform tests/fixtures/ref.txt tests/fixtures/xform.pickle --format txt")
    r = run(cmd + args, stdout=PIPE, universal_newlines=False)
    assert not r.returncode
    deg = tmpdir.join("deg.txt")
    deg.write_binary(r.stdout)

    # Generate alignment
    args = split("align tests/fixtures/ref.txt '{}' --format print".format(str(deg)))
    r = run(cmd + args, stdout=PIPE, universal_newlines=False)
    assert not r.returncode
Пример #9
0
def test_print(tmpdir):
    expected = loadPoints(Path("tests/fixtures/ref.txt"))

    # Generate degraded points (without noise)
    args = split(
        "xform tests/fixtures/ref.txt tests/fixtures/xform.pickle --format txt"
    )
    r = run(cmd + args, stdout=PIPE, universal_newlines=False)
    assert not r.returncode
    deg = tmpdir.join("deg.txt")
    deg.write_binary(r.stdout)

    # Generate alignment
    args = split("align tests/fixtures/ref.txt '{}' --format print".format(
        str(deg)))
    r = run(cmd + args, stdout=PIPE, universal_newlines=False)
    assert not r.returncode
Пример #10
0
def test_xform_inverse(tmpdir):
    expected = loadPoints(Path("tests/fixtures/ref.txt"))

    # Generate degraded points (without noise)
    args = split("xform tests/fixtures/ref.txt tests/fixtures/xform.pickle --format txt")
    r = run(cmd + args, stdout=PIPE, universal_newlines=False)
    assert not r.returncode
    deg = tmpdir.join("deg.txt")
    deg.write_binary(r.stdout)

    # Generate alignment
    args = split("align tests/fixtures/ref.txt '{}' "
                 "--format pickle --scope global".format(str(deg)))
    r = run(cmd + args, stdout=PIPE, universal_newlines=False)
    assert not r.returncode
    xform = tmpdir.join("xform.pickle")
    xform.write_binary(r.stdout)

    # Check alignment xform
    args = split("xform '{}' '{}' --format pickle".format(str(deg), str(xform)))
    r = run(cmd + args, stdout=PIPE, universal_newlines=False)
    assert not r.returncode
    result = loads(r.stdout)
    assert_almost_equal(expected, result)