-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add uncertainity aware rotation averaging #771
base: master
Are you sure you want to change the base?
Conversation
gtsfm/averaging/rotation/const.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we rename this file as gamma_values.py
or gamma_constants.py
to make the name a little more descriptive?
gtsfm/averaging/rotation/const.py
Outdated
@@ -0,0 +1,12290 @@ | |||
NU3 = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a module docstring and explain where these values come from?
@@ -0,0 +1,257 @@ | |||
""" | |||
Uncertainity aware rotation averaging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: typo
def random_rotation() -> Rot3: | ||
"""Sample a random rotation by generating a sample from the 4d unit sphere.""" | ||
q = np.random.randn(4) * 0.03 | ||
# make unit-length quaternion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: capitalization and punctuation
# Make unit-length quaternion.
global_rotations_init = initialize_global_rotations_using_mst( | ||
num_images, {key: value for key, value in i2Ri1_dict.items() if value is not None} | ||
) | ||
# global_rotations_init = [random_rotation() for _ in range(num_images)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we remove the commented out code?
ANGLE_AXIS_COVNORM = 8 | ||
|
||
|
||
class MAGSACWeightBasedLoss(pyceres.LossFunction): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we add a 1-line docstring for this class?
return _estimate_rotations_with_customized_loss_and_covariance_ceres(global_rotations_init, rotation_info_dict) | ||
|
||
|
||
class RotationInfo(NamedTuple): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we add an Attributes
section to describe each field here, and a 1-line sentence describing the class?
ROTATION_ANGLE_ERROR_THRESHOLD_DEG = 2 | ||
|
||
|
||
class TestUncertainityAwareRotationAveraging(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: typo "Uncertainty"
"""Helper function to run the averagaing and assert w/ expected. | ||
|
||
Args: | ||
i2Ri1_input: relative rotations, which are input to the algorithm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: capitalization
i2Ri1_input: Relative rotations, which are provided as input to the algorithm.
|
||
self.__execute_test(i2Ri1_dict, expected_wRi_list) | ||
|
||
# def test_simple_with_prior(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we remove this commented-out code?
costs.append(cost) | ||
problem.add_residual_block( | ||
cost, | ||
# pyceres.TrivialLoss(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we remove this commented out code?
self.weight_zero = self.one_over_sigma * self.gamma_difference | ||
self.use_weight_inverse = inverse | ||
|
||
def Evaluate(self, squared_residual, rho): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we add type annotations?
|
||
|
||
class MAGSACWeightBasedLoss(pyceres.LossFunction): | ||
def __init__(self, sigma, inverse=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we add type annotations?
No description provided.