Skip to content

Commit

Permalink
fix: fix chance of not slicing properly
Browse files Browse the repository at this point in the history
  • Loading branch information
bmccalmon committed Aug 12, 2024
1 parent f68a37a commit 26afad7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pyfishsensedev/fish/fish_head_tail_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ def classify_coords(self, mask: np.ndarray, coords: Tuple[np.ndarray, np.ndarray

# find the line perpendicular to the line connecting the points
ab = shapely.geometry.LineString(coords)
ab_left = ab.parallel_offset(abs(perimeter[:,1].min() - ab.centroid.y), 'left')
ab_right = ab.parallel_offset(abs(perimeter[:,1].max() - ab.centroid.y), 'right')
ab_left = ab.parallel_offset(abs(perimeter[:,1].min() - ab.centroid.y)+10, 'left')
ab_right = ab.parallel_offset(abs(perimeter[:,1].max() - ab.centroid.y)+10, 'right')
ab_perp = shapely.geometry.LineString([ab_left.centroid, ab_right.centroid])

# let's recalculate ab so that it's long enough to slice the polygon horizontally
ab_perp_left = ab_perp.parallel_offset(abs(perimeter[:,0].min() - ab_perp.centroid.x), 'left')
ab_perp_right = ab_perp.parallel_offset(abs(perimeter[:,0].max() - ab_perp.centroid.x), 'right')
ab_perp_left = ab_perp.parallel_offset(abs(perimeter[:,0].min() - ab_perp.centroid.x)+10, 'left')
ab_perp_right = ab_perp.parallel_offset(abs(perimeter[:,0].max() - ab_perp.centroid.x)+10, 'right')
ab = shapely.geometry.LineString([ab_perp_left.centroid, ab_perp_right.centroid])

# create a polygon
Expand Down

0 comments on commit 26afad7

Please sign in to comment.