From 84d977619e2348ec0b5bc052643295a33c633aed Mon Sep 17 00:00:00 2001 From: Shuo Zhong Date: Wed, 6 Sep 2023 11:10:48 -0400 Subject: [PATCH] fix features zero division causing nan value --- opensfm/features.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/opensfm/features.py b/opensfm/features.py index c576fbc23..7ba2e44d5 100644 --- a/opensfm/features.py +++ b/opensfm/features.py @@ -285,6 +285,7 @@ def root_feature(desc: np.ndarray, l2_normalization: bool = False) -> np.ndarray desc = (desc.T / s2).T s = np.sum(desc, 1) desc = np.sqrt(desc.T / s).T + desc[np.isnan(desc)] = 0 return desc @@ -308,6 +309,7 @@ def root_feature_surf( s_sub = np.sum(np.abs(desc), 1) desc_sub = np.sqrt(desc_sub.T / s_sub).T desc[:, ii] = desc_sub * desc_sub_sign + desc[np.isnan(desc)] = 0 return desc