Ejemplo n.º 1
0
def test_essential_matrix_inverse(xp):
    tform = EssentialMatrixTransform(rotation=xp.eye(3),
                                     translation=xp.array([1, 0, 0]),
                                     xp=xp)
    src = xp.array([[0, 0], [0, 1], [1, 1]])
    assert_array_almost_equal(tform.inverse(src),
                              xp.array([[0, 1, 0], [0, 1, -1], [0, 1, -1]]))
Ejemplo n.º 2
0
def test_essential_matrix_residuals(xp):
    tform = EssentialMatrixTransform(rotation=xp.eye(3),
                                     translation=xp.array([1, 0, 0]),
                                     xp=xp)
    src = xp.array([[0, 0], [0, 0], [0, 0]])
    dst = xp.array([[2, 0], [2, 1], [2, 2]])
    assert_array_almost_equal(
        tform.residuals(src, dst)**2, xp.array([0, 0.5, 2]))
Ejemplo n.º 3
0
def test_essential_matrix_init(xp):
    tform = EssentialMatrixTransform(rotation=xp.eye(3),
                                     translation=xp.array([0, 0, 1]),
                                     xp=xp)

    assert_array_equal(tform.params,
                       xp.array([0, -1, 0, 1, 0, 0, 0, 0, 0]).reshape(3, 3))
Ejemplo n.º 4
0
def test_fundamental_matrix_inverse(xp):
    essential_matrix_tform = EssentialMatrixTransform(rotation=xp.eye(3),
                                                      translation=xp.array(
                                                          [1, 0, 0]),
                                                      xp=xp)
    tform = FundamentalMatrixTransform()
    tform.params = essential_matrix_tform.params
    src = xp.array([[0, 0], [0, 1], [1, 1]])
    assert_array_almost_equal(tform.inverse(src),
                              xp.array([[0, 1, 0], [0, 1, -1], [0, 1, -1]]))
Ejemplo n.º 5
0
def test_invalid_input(xp):
    with pytest.raises(ValueError):
        ProjectiveTransform(xp.zeros((2, 3)))
    with pytest.raises(ValueError):
        AffineTransform(xp.zeros((2, 3)))
    with pytest.raises(ValueError):
        SimilarityTransform(xp.zeros((2, 3)))
    with pytest.raises(ValueError):
        EuclideanTransform(xp.zeros((2, 3)))
    with pytest.raises(ValueError):
        AffineTransform(matrix=xp.zeros((2, 3)), scale=1)
    with pytest.raises(ValueError):
        SimilarityTransform(matrix=xp.zeros((2, 3)), scale=1)
    with pytest.raises(ValueError):
        EuclideanTransform(matrix=xp.zeros((2, 3)), translation=(0, 0))
    with pytest.raises(ValueError):
        PolynomialTransform(xp.zeros((3, 3)))
    with pytest.raises(ValueError):
        FundamentalMatrixTransform(matrix=xp.zeros((3, 2)))
    with pytest.raises(ValueError):
        EssentialMatrixTransform(matrix=xp.zeros((3, 2)))

    with pytest.raises(ValueError):
        EssentialMatrixTransform(rotation=xp.zeros((3, 2)))
    with pytest.raises(ValueError):
        EssentialMatrixTransform(rotation=xp.zeros((3, 3)))
    with pytest.raises(ValueError):
        EssentialMatrixTransform(rotation=xp.eye(3))
    with pytest.raises(ValueError):
        EssentialMatrixTransform(rotation=xp.eye(3),
                                 translation=xp.zeros((2, )),
                                 xp=xp)
    with pytest.raises(ValueError):
        EssentialMatrixTransform(rotation=xp.eye(3),
                                 translation=xp.zeros((2, )),
                                 xp=xp)
    with pytest.raises(ValueError):
        EssentialMatrixTransform(rotation=xp.eye(3),
                                 translation=xp.zeros((3, )),
                                 xp=xp)