Skip to content

Commit

Permalink
Target tracker amend (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvanuy authored Oct 20, 2023
1 parent ed24f03 commit 62e3151
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/imaging_target_tracker_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ def test_with_certain_match(self):
target_1, target_2
]

desc = TargetDescription(1,3,3,7)
desc = TargetDescription(
np.eye(13)[1],
np.eye(35)[3],
np.eye(8)[3],
np.eye(8)[7],
)

assert tracker.closest_match(desc) is target_1

def test_with_near_match(self):
Expand Down Expand Up @@ -67,6 +73,11 @@ def test_with_near_match(self):
target_1, target_2
]

desc = TargetDescription(2,2,2,7)
desc = TargetDescription(
np.eye(13)[2],
np.eye(35)[2],
np.eye(8)[2],
np.eye(8)[7],
)
assert tracker.closest_match(desc) is target_2

11 changes: 11 additions & 0 deletions uavf_2024/imaging/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@

from .imaging_types import TargetDescription, Tile


def normalize_distribution( b: TargetDescription, offset):
shape_norm_prob = (b.shape_probs + offset)/sum(b.shape_probs + offset)
letter_norm_prob = (b.letter_probs + offset)/sum(b.letter_probs + offset)
shape_col_norm_prob = (b.shape_col_probs + offset)/sum(b.shape_col_probs + offset)
letter_col_norm_prob = (b.letter_col_probs + offset)/sum(b.letter_col_probs + offset)

return TargetDescription(shape_norm_prob, letter_norm_prob, shape_col_norm_prob, letter_col_norm_prob)


def calc_match_score(a: TargetDescription, b: TargetDescription):
'''
Returns a number between 0 and 1 representing how likely the two descriptions are the same target
'''
b = normalize_distribution(b, 1e-4)
shape_score = sum(a.shape_probs * b.shape_probs)
letter_score = sum(a.letter_probs * b.letter_probs)
shape_color_score = sum(a.shape_col_probs * b.shape_col_probs)
Expand Down

0 comments on commit 62e3151

Please sign in to comment.