Skip to content

Commit

Permalink
Check and only convert valid polygon with at least 3 points to mask
Browse files Browse the repository at this point in the history
  • Loading branch information
healthonrails committed Mar 12, 2024
1 parent 0830f2d commit 0cbad07
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions annolid/segmentation/SAM/edge_sam_bg.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ def process_video_with_cutite(self, frames_to_propagate=100,
frame_number = int(
Path(self.most_recent_file).stem.split('_')[-1])
shapes = self.load_shapes(self.most_recent_file)
shapes = [shape for shape in shapes if len(shape["points"]) >= 3]
if len(shapes) < 1:
return f"No valid polygon found in this frame; requires a minimum of 3 points #{frame_number} "
for shape in sorted(shapes, key=lambda x: x["label"]):
label_name = shape["label"]
if label_name in label_name_to_value:
Expand Down

0 comments on commit 0cbad07

Please sign in to comment.