add test for shape of transformation matrix

This commit is contained in:
Johannes Schönberger
2012-08-10 08:15:06 +02:00
parent 724a931d42
commit 8ab0c9a329
+14 -6
View File
@@ -105,6 +105,8 @@ class ProjectiveTransform(GeometricTransform):
coeffs = range(8)
def __init__(self, matrix=None):
if matrix is not None and matrix.shape != (3, 3):
raise ValueError("invalid shape of transformation matrix")
self._matrix = matrix
@property
@@ -269,10 +271,12 @@ class AffineTransform(ProjectiveTransform):
def __init__(self, matrix=None, scale=None, rotation=None, shear=None,
translation=None):
if matrix is not None and matrix.shape != (3, 3):
raise ValueError("invalid shape of transformation matrix")
self._matrix = matrix
params = (scale, rotation, shear, translation)
if matrix is not None:
self._matrix = matrix
elif any(param is not None for param in params):
if any(param is not None for param in params):
if scale is None:
scale = (1, 1)
if rotation is None:
@@ -340,10 +344,12 @@ class SimilarityTransform(ProjectiveTransform):
def __init__(self, matrix=None, scale=None, rotation=None,
translation=None):
if matrix is not None and matrix.shape != (3, 3):
raise ValueError("invalid shape of transformation matrix")
self._matrix = matrix
params = (scale, rotation, translation)
if matrix is not None:
self._matrix = matrix
elif any(param is not None for param in params):
if any(param is not None for param in params):
if scale is None:
scale = 1
if rotation is None:
@@ -460,6 +466,8 @@ class PolynomialTransform(GeometricTransform):
"""
def __init__(self, params=None):
if params is not None and params.shape[0] != 2:
raise ValueError("invalid shape of transformation parameters")
self._params = params
def estimate(self, src, dst, order):