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

Use average coordinate of merged keypoints during NMS #711

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,16 @@ def append_unique_keypoints(

for k, uv in enumerate(keypoints.coordinates):
diff_norms = np.linalg.norm(per_image_kpt_coordinates[i] - uv, axis=1)
# TODO(johnwlambert,travisdriver): Use the average coordinate instead of first coordinate.
is_duplicate = np.any(diff_norms <= self.nms_merge_radius)
if len(per_image_kpt_coordinates[i]) > 0 and is_duplicate:
Copy link
Collaborator

Choose a reason for hiding this comment

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

have you tested with len(per_image_kpt_coordinates[i]) == 0? does the <= work with empty arrrays?
Also np.any should be false in that case, so you would not need that condition at all?

self.duplicates_found += 1
i_indices[k] = np.argmin(diff_norms)
img_global_kpt_idx = np.argmin(diff_norms)
i_indices[k] = img_global_kpt_idx
# Modify global keypoint coordinate to be set to average value of merged detections, instead of
# using the first identified coordinate.
updated_uv = np.mean([per_image_kpt_coordinates[i][img_global_kpt_idx], uv], axis=0)
per_image_kpt_coordinates[i][img_global_kpt_idx] = updated_uv
Comment on lines +59 to +62
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't you take the mean after you've determined which keypoints are to be merged?


else:
i_indices[k] = i_count
i_count += 1
Expand Down
Loading