Skip to content

Commit eb2af80

Browse files
committed
prevent max points reached printing spam
1 parent 0fb469b commit eb2af80

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

script.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ def mouse_callback(
186186
_param,
187187
):
188188
if len(self.points) >= self.max_points:
189-
print(
190-
"Maximum number of points (2) reached. Press ENTER to continue or 'c' to clear."
191-
)
189+
if not hasattr(self, "max_points_reached"):
190+
print(
191+
"Maximum number of points (2) reached. Press ENTER to continue or 'c' to clear."
192+
)
193+
self.max_points_reached = True
192194
return
193195

194196
if event == cv2.EVENT_LBUTTONDOWN: # Left click for foreground
@@ -207,6 +209,10 @@ def mouse_callback(
207209
f"Added background point at ({x}, {y}). {points_left} point{'s' if points_left != 1 else ''} remaining."
208210
)
209211

212+
# Reset the flag if points are cleared
213+
if len(self.points) < self.max_points and hasattr(self, "max_points_reached"):
214+
delattr(self, "max_points_reached")
215+
210216
def _update_display(self):
211217
self.display_image = self.image.copy()
212218

0 commit comments

Comments
 (0)