Skip to content

Commit e9288f5

Browse files
introduce additional constraints for individual object point coordinates
1 parent 57d7ec0 commit e9288f5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bacs/bacs.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def bacs(l, ict, Sll, Xa, Ma, P, *,
2929
near_ratio = 1.0,
3030
sigma_h = (0, 0, 0, 0, 0, 0, 100),
3131
sigma_c = None,
32+
sigma_i = None,
3233
):
3334
"""
3435
Perform a bundle adjustment for multi-view cameras based on
@@ -64,6 +65,7 @@ def bacs(l, ict, Sll, Xa, Ma, P, *,
6465
near_ratio fraction of scene points used for datum definition (default: 1 -> all)
6566
sigma_h variances of centroid constraints (3 translations, 3 rotations, 1 scale, default: (0,0,0,0,0,0,100))
6667
sigma_c variances of camera motion constraints (experimental, length 6xT, default: None)
68+
sigma_i variances of object point constraints (experimental, length 3xI, default: None)
6769
6870
Output:
6971
la estimated camera rays [3xN]
@@ -83,7 +85,9 @@ def bacs(l, ict, Sll, Xa, Ma, P, *,
8385
T = len(Ma)
8486
c_indices = [k for k, s in enumerate(sigma_c) if s is not None and np.isfinite(s)] if sigma_c is not None else []
8587
sigma_c = [s for s in sigma_c if s is not None and np.isfinite(s)] if sigma_c is not None else []
86-
Shh = sparse.diags(list(sigma_h) + sigma_c)**2
88+
i_indices = [k for k, s in enumerate(sigma_i) if s is not None and np.isfinite(s)] if sigma_i is not None else []
89+
sigma_i = [s for s in sigma_i if s is not None and np.isfinite(s)] if sigma_i is not None else []
90+
Shh = sparse.diags(list(sigma_h) + sigma_c + sigma_i)**2
8791
d = Shh.shape[0]
8892
r = 2 * N - 3 * I - 6 * T + d
8993
if r < 0:
@@ -152,6 +156,10 @@ def bacs(l, ict, Sll, Xa, Ma, P, *,
152156
t = index // 6
153157
R = Ma_inv[t][:3, :3].T # restrict rotated translation parameters
154158
Nside[3 * I + 6 * t + 3 : 3 * I + 6 * t + 6, 7 + k] = R[index % 6 - 3]
159+
for k, index in enumerate(i_indices):
160+
i = index // 3
161+
R = nullXa[:, :, i]
162+
Nside[3 * i : 3 * i + 3, 7 + len(c_indices) + k] = R[index % 3] # restrict rotated object points
155163

156164
# parameter and observation updates
157165
A = sparse.hstack((C, D))

0 commit comments

Comments
 (0)