Skip to content

Commit ec87ceb

Browse files
adjustments tohandle unexpected linear trajectory fitting
1 parent 6928fbc commit ec87ceb

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/reconstruction/lookup.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,11 @@ def find_plane(camera: Camera,
790790
camera.K,
791791
camera.dist_coeffs)
792792
rvec = result['rvec'].ravel()
793+
# this is an arbitrary choice to avoid the cases with
794+
# indistinguishable rvec and -rvec, so make it such
795+
# that rvec[-1] is always positive
796+
if rvec[-1] < 0:
797+
rvec *= -1.
793798
tvec = result['tvec'].ravel()
794799

795800
save_json({
@@ -823,7 +828,9 @@ def fit_plane_trajectory(calibration_directory):
823828
N = -N
824829
middle_index = np.nanargmin(np.linalg.norm(tvecs - C, axis=1))
825830

826-
steps = np.linalg.norm(np.diff(tvecs, axis=0), axis=1)
831+
# this dot product works because we enforced \|N\|^2 = 1.0,
832+
# so we don't need to divide it by that to get the step in the N direction
833+
steps = np.dot(np.diff(tvecs, axis=0), N)
827834
idx = np.abs(steps - np.nanmedian(steps)) < np.nanstd(steps)
828835
stride = np.nanmean(steps[idx])
829836

0 commit comments

Comments
 (0)