Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

ayushbaid
Copy link
Contributor

No description provided.

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