Tracking¶
Scoring¶
Defines some functions that compare features and score them.
Deprecated scoring functions are not imported to the parent module!
Note
Functions with suffix _v are vectorized with numpy.
-
score_ids_best_fit(ids1, ids2, length=12)[source]¶ Compares two lists of ids by choosing the pair with the best score.
Deprecated since version September: 2016 This scoring is used with data from the old Computer Vision Pipeline.
Parameters: Keyword Arguments: length (Optional int) – number of bits in the bit array used to compare ids
Returns: Uses Hamming distance of best matching pair
Return type:
-
score_ids_best_fit_rotating(ids1, ids2, rotation_penalty=1, length=12)[source]¶ Compares two lists of ids by choosing the pair best score by rotating the bits.
Deprecated since version September: 2016 This scoring is used with data from the old Computer Vision Pipeline.
Parameters: Keyword Arguments: - rotation_penalty (Optional float) – the penalty that is added for a rotation of 1 to the left or right
- length (Optional int) – number of bits in the bit array used to compare ids
Returns: Uses Hamming distance of best matching (rotated) pair
Return type:
-
score_ids_and_orientation(id_orientation_tuple1, id_orientation_tuple2, length=12, range_bonus_orientation=30)[source]¶ Compares lists of ids by choosing the pair with the best score and considering orientation.
The bonus is equal to the negative score of one non matching bit.
Deprecated since version September: 2016 This scoring is used with data from the old Computer Vision Pipeline.
Parameters: Keyword Arguments: Returns: Uses Hamming distance of best matching pair with bonus for same orientation
Return type:
-
score_id_sim(id1, id2)[source]¶ Compares two id frequency distributions for similarity
Parameters: Returns: Use Manhattan distance \(\sum_i |id1_i - id2_i|\)
Return type:
-
score_id_sim_v(detections1, detections2)[source]¶ Compares two id frequency distributions for similarity (vectorized)
Parameters: Returns: Use Manhattan distance \(\sum_i |id1_i - id2_i|\)
Return type: np.array
-
score_id_sim_orientation(id1, or1, id2, or2, range_bonus_orientation=30, value_bonus_orientation=1.0)[source]¶ Compares two id frequency distributions for similarity
Parameters: Keyword Arguments: - range_bonus_orientation (Optional float) – range in degrees, so that two orientations get a bonus
- value_bonus_orientation (Optional float) – value to add if orientations are within range_bonus_orientation
Returns: Use Manhattan distance \(\sum_i |id1_i - id2_i|\)
Return type:
-
score_id_sim_orientation_v(detections1, detections2, range_bonus_orientation=0.5235987755982988, value_bonus_orientation=1.0)[source]¶ Compares id frequency distributions for similarity (vectorized)
Parameters: Keyword Arguments: - range_bonus_orientation (Optional float) – range in degrees, so that two orientations get a bonus
- value_bonus_orientation (Optional float) – value to add if orientations are within range_bonus_orientation
Returns: Use Manhattan distance \(\sum_i |id1_i - id2_i|\)
Return type: np.array
-
score_id_sim_rotating(id1, id2, rotation_penalty=0.5)[source]¶ Compares two id frequency distributions for similarity by rotating them
Instead of only using the distance metric, one id is rotated to check for better results.
Parameters: Keyword Arguments: rotation_penalty (float) – the penalty that is added for a rotation of 1 to the left or right
Returns: Manhattan distance but also rotated with added rotation_penalty.
Return type:
-
score_id_sim_rotating_v(detections1, detections2, rotation_penalty=0.5)[source]¶ Compares id frequency distributions for similarity by rotating them (vectorized)
Instead of only using the distance metric, one id is rotated to check for better results.
Note
The calculation of this feature is quite expensiv compared to
score_id_sim_v()!Parameters: Keyword Arguments: rotation_penalty (Optional float) – the penalty that is added for a rotation of 1 to the left or right
Returns: Manhattan distance but also rotated with added rotation_penalty.
Return type: np.array
-
score_id_sim_tracks_median_v(tracks1, tracks2)[source]¶ Compares id frequency distributions of tracks by comparing the median (vectorized)
Parameters: Returns: Use Manhattan distance \(\sum_i |Median(ids1)_i - Median(ids2)_i|\)
Return type: np.array
-
distance_orientations(rad1, rad2)[source]¶ Calculates the distance between two orientations.
Orientations in rad are converted to degrees then the difference is calculated.
Parameters: Returns: distance between two orientation in degrees, e.g. 90 for -pi/2 and pi
Return type:
-
distance_orientations_v(detections1, detections2, meta_key=None)[source]¶ Calculates the distances between orientations (vectorized)
Orientations are expected to be in rad.
Parameters: Keyword Arguments: meta_key (Optional str) – Instead of
Detection.orientationuse value fromDetection.metaReturns: distance between orientations of detections line by line in rad
Return type: np.array
-
distance_positions_v(detections1, detections2)[source]¶ Calculates the euclidean distances between the x and y positions (vectorized)
Parameters: Returns: Euclidean distance between detections line by line
Return type: np.array
-
bit_array_to_int_v(bit_arrays, threshold=0.5, endian='little')[source]¶ Converts the bit frequency distribution of the id to an integer representation.
Note
Instead of bit_arrays you could also pass lists with
Detectionobjects. In this case theDetection.beeIdis used and interpreted as bit array.Parameters: bit_arrays (
listof arrays orDetection) – Iterable with ids to decode.Keyword Arguments: - threshold (Optional float) –
values >= thresholdare interpreted as 1 - endian (Optional str) – Either little for little endianess or big for big endianess.
Returns: the decoded ids represented as integer
Return type: listof int- threshold (Optional float) –
-
calc_median_ids(tracks)[source]¶ Helper to calculate the median bit for all the ids in the given track.
Note
For performance reasons the median id is saved as meta key and only is recalculated if the length of the track changes.
Parameters: tracks ( listofTrack) – Iterable with TracksReturns: median for all the bits in the given track Return type: np.array
-
calc_track_ids(tracks)[source]¶ Function to calculate an id for a
Track.This functions calculates the median for each bit of the detections in the track and then uses a threshold to decide whether a bit is set or not.
Note
Used as default implementation to calculate
Score.calc_id.Parameters: tracks ( listofTrack) – A list ofTrackobject to calculate an id based on it’s list ofDetectionobjects.Returns: the calculated id for the TrackReturn type: int