···
1
+
diff --git a/opensfm/exif.py b/opensfm/exif.py
2
+
--- a/opensfm/exif.py
3
+
+++ b/opensfm/exif.py
4
+
@@ -509,7 +509,7 @@ class EXIF:
8
+
- if np.all(ypr) is not None:
9
+
+ if np.all(ypr != None):
10
+
ypr = np.radians(ypr)
12
+
# Convert YPR --> OPK
13
+
diff --git a/opensfm/transformations.py b/opensfm/transformations.py
14
+
--- a/opensfm/transformations.py
15
+
+++ b/opensfm/transformations.py
16
+
@@ -232,7 +232,7 @@ def translation_from_matrix(matrix: numpy.ndarray) -> numpy.ndarray:
20
+
- return numpy.array(matrix, copy=False)[:3, 3].copy()
21
+
+ return numpy.asarray(matrix)[:3, 3].copy()
24
+
def reflection_matrix(point: numpy.ndarray, normal: numpy.ndarray) -> numpy.ndarray:
25
+
@@ -275,7 +275,7 @@ def reflection_from_matrix(
29
+
- M = numpy.array(matrix, dtype=numpy.float64, copy=False)
30
+
+ M = numpy.asarray(matrix, dtype=numpy.float64)
31
+
# normal: unit eigenvector corresponding to eigenvalue -1
32
+
w, V = numpy.linalg.eig(M[:3, :3])
33
+
i = numpy.where(abs(numpy.real(w) + 1.0) < 1e-8)[0]
34
+
@@ -339,7 +339,7 @@ def rotation_matrix(
36
+
if point is not None:
37
+
# rotation not around origin
38
+
- point = numpy.array(point[:3], dtype=numpy.float64, copy=False)
39
+
+ point = numpy.asarray(point[:3], dtype=numpy.float64)
40
+
M[:3, 3] = point - numpy.dot(R, point)
43
+
@@ -359,7 +359,7 @@ def rotation_from_matrix(
47
+
- R = numpy.array(matrix, dtype=numpy.float64, copy=False)
48
+
+ R = numpy.asarray(matrix, dtype=numpy.float64)
50
+
# direction: unit eigenvector of R33 corresponding to eigenvalue of 1
51
+
w, W = numpy.linalg.eig(R33.T)
52
+
@@ -444,7 +444,7 @@ def scale_from_matrix(
56
+
- M = numpy.array(matrix, dtype=numpy.float64, copy=False)
57
+
+ M = numpy.asarray(matrix, dtype=numpy.float64)
59
+
factor = numpy.trace(M33) - 2.0
61
+
@@ -505,11 +505,11 @@ def projection_matrix(
64
+
M = numpy.identity(4)
65
+
- point = numpy.array(point[:3], dtype=numpy.float64, copy=False)
66
+
+ point = numpy.asarray(point[:3], dtype=numpy.float64)
67
+
normal = unit_vector(normal[:3])
68
+
if perspective is not None:
69
+
# perspective projection
70
+
- perspective = numpy.array(perspective[:3], dtype=numpy.float64, copy=False)
71
+
+ perspective = numpy.asarray(perspective[:3], dtype=numpy.float64)
72
+
M[0, 0] = M[1, 1] = M[2, 2] = numpy.dot(perspective - point, normal)
73
+
M[:3, :3] -= numpy.outer(perspective, normal)
75
+
@@ -522,7 +522,7 @@ def projection_matrix(
76
+
M[3, 3] = numpy.dot(perspective, normal)
77
+
elif direction is not None:
78
+
# parallel projection
79
+
- direction = numpy.array(direction[:3], dtype=numpy.float64, copy=False)
80
+
+ direction = numpy.asarray(direction[:3], dtype=numpy.float64)
81
+
scale = numpy.dot(direction, normal)
82
+
M[:3, :3] -= numpy.outer(direction, normal) / scale
83
+
M[:3, 3] = direction * (numpy.dot(point, normal) / scale)
84
+
@@ -569,7 +569,7 @@ def projection_from_matrix(
88
+
- M = numpy.array(matrix, dtype=numpy.float64, copy=False)
89
+
+ M = numpy.asarray(matrix, dtype=numpy.float64)
91
+
w, V = numpy.linalg.eig(M)
92
+
i = numpy.where(abs(numpy.real(w) - 1.0) < 1e-8)[0]
93
+
@@ -726,7 +726,7 @@ def shear_from_matrix(
97
+
- M = numpy.array(matrix, dtype=numpy.float64, copy=False)
98
+
+ M = numpy.asarray(matrix, dtype=numpy.float64)
100
+
# normal: cross independent eigenvectors corresponding to the eigenvalue 1
101
+
w, V = numpy.linalg.eig(M33)
102
+
@@ -790,7 +790,7 @@ def decompose_matrix(
106
+
- M = numpy.array(matrix, dtype=numpy.float64, copy=True).T
107
+
+ M = numpy.asarray(matrix, dtype=numpy.float64, copy=True).T
108
+
if abs(M[3, 3]) < _EPS:
109
+
raise ValueError("M[3, 3] is zero")
111
+
@@ -982,8 +982,8 @@ def affine_matrix_from_points(
112
+
More examples in superimposition_matrix()
115
+
- v0 = numpy.array(v0, dtype=numpy.float64, copy=True)
116
+
- v1 = numpy.array(v1, dtype=numpy.float64, copy=True)
117
+
+ v0 = numpy.asarray(v0, dtype=numpy.float64, copy=True)
118
+
+ v1 = numpy.asarray(v1, dtype=numpy.float64, copy=True)
120
+
ndims = v0.shape[0]
121
+
if ndims < 2 or v0.shape[1] < ndims or v0.shape != v1.shape:
122
+
@@ -1099,8 +1099,8 @@ def superimposition_matrix(
126
+
- v0 = numpy.array(v0, dtype=numpy.float64, copy=False)[:3]
127
+
- v1 = numpy.array(v1, dtype=numpy.float64, copy=False)[:3]
128
+
+ v0 = numpy.asarray(v0, dtype=numpy.float64)[:3]
129
+
+ v1 = numpy.asarray(v1, dtype=numpy.float64)[:3]
130
+
return affine_matrix_from_points(v0, v1, shear=False, scale=scale, usesvd=usesvd)
133
+
@@ -1198,7 +1198,7 @@ def euler_from_matrix(
134
+
j = _NEXT_AXIS[i + parity]
135
+
k = _NEXT_AXIS[i - parity + 1]
137
+
- M = numpy.array(matrix, dtype=numpy.float64, copy=False)[:3, :3]
138
+
+ M = numpy.asarray(matrix, dtype=numpy.float64)[:3, :3]
140
+
sy = math.sqrt(M[i, j] * M[i, j] + M[i, k] * M[i, k])
142
+
@@ -1329,7 +1329,7 @@ def quaternion_matrix(quaternion: numpy.ndarray) -> numpy.ndarray:
146
+
- q = numpy.array(quaternion, dtype=numpy.float64, copy=True)
147
+
+ q = numpy.asarray(quaternion, dtype=numpy.float64, copy=True)
148
+
n = numpy.dot(q, q)
150
+
return numpy.identity(4)
151
+
@@ -1379,7 +1379,7 @@ def quaternion_from_matrix(
155
+
- M = numpy.array(matrix, dtype=numpy.float64, copy=False)[:4, :4]
156
+
+ M = numpy.asarray(matrix, dtype=numpy.float64)[:4, :4]
158
+
q = numpy.empty((4,))
160
+
@@ -1460,7 +1460,7 @@ def quaternion_conjugate(quaternion: numpy.ndarray) -> numpy.ndarray:
164
+
- q = numpy.array(quaternion, dtype=numpy.float64, copy=True)
165
+
+ q = numpy.asarray(quaternion, dtype=numpy.float64, copy=True)
166
+
numpy.negative(q[1:], q[1:])
169
+
@@ -1474,7 +1474,7 @@ def quaternion_inverse(quaternion: numpy.ndarray) -> numpy.ndarray:
173
+
- q = numpy.array(quaternion, dtype=numpy.float64, copy=True)
174
+
+ q = numpy.asarray(quaternion, dtype=numpy.float64, copy=True)
175
+
numpy.negative(q[1:], q[1:])
176
+
return q / numpy.dot(q, q)
178
+
@@ -1496,7 +1496,7 @@ def quaternion_imag(quaternion: numpy.ndarray) -> numpy.ndarray:
179
+
array([ 0., 1., 2.])
182
+
- return numpy.array(quaternion[1:4], dtype=numpy.float64, copy=True)
183
+
+ return numpy.asarray(quaternion[1:4], dtype=numpy.float64, copy=True)
186
+
def quaternion_slerp(
187
+
@@ -1654,7 +1654,7 @@ def vector_norm(
191
+
- data = numpy.array(data, dtype=numpy.float64, copy=True)
192
+
+ data = numpy.asarray(data, dtype=numpy.float64, copy=True)
195
+
return math.sqrt(numpy.dot(data, data))
196
+
@@ -1697,13 +1697,13 @@ def unit_vector(
200
+
- data = numpy.array(data, dtype=numpy.float64, copy=True)
201
+
+ data = numpy.asarray(data, dtype=numpy.float64, copy=True)
203
+
data /= math.sqrt(numpy.dot(data, data))
206
+
if out is not data:
207
+
- out[:] = numpy.array(data, copy=False)
208
+
+ out[:] = numpy.asarray(data)
210
+
length = numpy.atleast_1d(numpy.sum(data * data, axis))
211
+
numpy.sqrt(length, length)
212
+
@@ -1777,8 +1777,8 @@ def angle_between_vectors(
216
+
- v0 = numpy.array(v0, dtype=numpy.float64, copy=False)
217
+
- v1 = numpy.array(v1, dtype=numpy.float64, copy=False)
218
+
+ v0 = numpy.asarray(v0, dtype=numpy.float64)
219
+
+ v1 = numpy.asarray(v1, dtype=numpy.float64)
220
+
dot = numpy.sum(v0 * v1, axis=axis)
221
+
dot /= vector_norm(v0, axis=axis) * vector_norm(v1, axis=axis)
222
+
dot = numpy.clip(dot, -1.0, 1.0)
223
+
@@ -1826,9 +1826,9 @@ def is_same_transform(matrix0: numpy.ndarray, matrix1: numpy.ndarray) -> numpy.n
227
+
- matrix0 = numpy.array(matrix0, dtype=numpy.float64, copy=True)
228
+
+ matrix0 = numpy.asarray(matrix0, dtype=numpy.float64, copy=True)
229
+
matrix0 /= matrix0[3, 3]
230
+
- matrix1 = numpy.array(matrix1, dtype=numpy.float64, copy=True)
231
+
+ matrix1 = numpy.asarray(matrix1, dtype=numpy.float64, copy=True)
232
+
matrix1 /= matrix1[3, 3]
233
+
return numpy.allclose(matrix0, matrix1)
235
+
@@ -1874,3 +1874,4 @@ if __name__ == "__main__":
237
+
numpy.set_printoptions(suppress=True, precision=5)