Skip to content

Add uncertainity aware rotation averaging#771

Open
ayushbaid wants to merge 14 commits intomasterfrom
feature/uncertainityAwareRotAvg
Open

Add uncertainity aware rotation averaging#771
ayushbaid wants to merge 14 commits intomasterfrom
feature/uncertainityAwareRotAvg

Conversation

@ayushbaid
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Collaborator

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?

@@ -0,0 +1,12290 @@
NU3 = 3
Copy link
Copy Markdown
Collaborator

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.
Copy link
Copy Markdown
Collaborator

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
Copy link
Copy Markdown
Collaborator

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)]
Copy link
Copy Markdown
Collaborator

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):
Copy link
Copy Markdown
Collaborator

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):
Copy link
Copy Markdown
Collaborator

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):
Copy link
Copy Markdown
Collaborator

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.
Copy link
Copy Markdown
Collaborator

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):
Copy link
Copy Markdown
Collaborator

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(),
Copy link
Copy Markdown
Collaborator

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):
Copy link
Copy Markdown
Collaborator

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):
Copy link
Copy Markdown
Collaborator

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?

@ayushbaid ayushbaid marked this pull request as ready for review February 20, 2024 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants