Skip to content

Commit

Permalink
Convert rectangle to polygon for zone or place preference counting
Browse files Browse the repository at this point in the history
This change converts the representation of rectangular zones or places from two points (top-left and bottom-right) to a polygon with four vertices. This ensures compatibility with systems that require polygonal shapes for zone or place preference counting.
  • Loading branch information
healthonrails committed Jun 13, 2024
1 parent 8bc2dfe commit a0534e6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions annolid/postprocessing/tracking_results_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']):
Expand Down

0 comments on commit a0534e6

Please sign in to comment.