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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vanilla ICP #2875

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Vanilla ICP #2875

wants to merge 1 commit into from

Conversation

jeffin07
Copy link
Contributor

@jeffin07 jeffin07 commented Apr 7, 2024

Changes

Added Vanilla ICP

Fixes # (issue)

#2649

Type of change

  • 馃敩 New feature (non-breaking change which adds functionality)
  • 馃摑 This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Did you update CHANGELOG in case of a major change?

@jeffin07
Copy link
Contributor Author

jeffin07 commented Apr 7, 2024

@edgarriba I have created an initial version. Can you please take a look at it ?

@jeffin07 jeffin07 marked this pull request as ready for review April 15, 2024 13:17


def iterative_closest_point(
points_in_a: torch.Tensor, points_in_b: torch.Tensor, max_iterations: int = 20, tolerance: float = 1e-4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
points_in_a: torch.Tensor, points_in_b: torch.Tensor, max_iterations: int = 20, tolerance: float = 1e-4
points_in_a: torch.Tensor, points_in_b: torch.Tensor, max_iterations: int = 20, tolerance: float = 1e-4, verbose: bool = False

The relative transformation between the two pointcloud with shape 3x4
"""

src = points_in_a.clone()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add some basic shape and type check
KORNIA_CHECK_SHAPE(points_in_a, ["B", "3"])


t = b_mean.T - R @ a_mean.T

points_in_a = (points_in_a.T @ R + t.unsqueeze(-1)).T
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
points_in_a = (points_in_a.T @ R + t.unsqueeze(-1)).T
points_in_a = points_in_a @ R + t


src = points_in_a.clone()
dst = points_in_b.clone()
prev_error = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prev_error = 0
prev_error = 0
R = torch.eye(3)
t = torch.zeros(3)


# print(points_in_a)

return 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 0
return torch.cat([R, t[:, None]], dim=1)

prev_error = mean_error
print(mean_error, iter)

# print(points_in_a)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# print(points_in_a)

if torch.abs(prev_error - mean_error) < tolerance:
break
prev_error = mean_error
print(mean_error, iter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(mean_error, iter)
if verbose:
print(f"ICP Mean error: {mean_error}, iter: {iter}")


Args:
points_in_a: The point cloud in the source coordinates frame A with shape Nx3
points_in_b: The point cloud in the source coordinates frame A with shape Nx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
points_in_b: The point cloud in the source coordinates frame A with shape Nx
points_in_b: The point cloud in the source coordinates frame A with shape Nx3

@cjpurackal
Copy link
Member

@jeffin07 can you write a test to verify the functionality?

@jeffin07 jeffin07 marked this pull request as draft May 14, 2024 17:36
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.

None yet

2 participants