diff --git a/annolid/postprocessing/tracking_results_analyzer.py b/annolid/postprocessing/tracking_results_analyzer.py index 7921e41..67fb03b 100644 --- a/annolid/postprocessing/tracking_results_analyzer.py +++ b/annolid/postprocessing/tracking_results_analyzer.py @@ -141,6 +141,18 @@ def determine_time_in_zone(self, instance_label): zone_time = 0 # Check if instance points are within the zone for _, row in instance_df.iterrows(): + if shape['shape_type'] == 'rectangle': + # Extract the given points + top_left = shape["points"][0] + bottom_right = shape["points"][1] + + # Calculate the other two points + top_right = [bottom_right[0], top_left[1]] + bottom_left = [top_left[0], bottom_right[1]] + + # Create the four-point representation + shape['points'] = [top_left, top_right, bottom_right, + bottom_left, top_left] # Closing the polygon if len(shape['points']) > 3: if self.is_point_in_polygon([row['cx_tracked'], row['cy_tracked']], shape['points']):