From b123b12d0d15d4ba5eccbf6f7e266ccabab9dedb Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Wed, 17 Sep 2025 15:46:39 +0200 Subject: [PATCH] Refactor motion path logic in VideoEditor for clarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit updates the VideoEditor class to improve the logic for drawing and checking motion paths between tracking points. The comments have been adjusted to clarify the conditions for drawing lines between previous→current and previous→next frames. Additionally, debug statements have been enhanced to provide clearer insights during the snapping process, ensuring better tracking point interactions. --- croppa/main.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/croppa/main.py b/croppa/main.py index 86fbfad..299bbe1 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -2033,14 +2033,14 @@ class VideoEditor: prev_result = self._get_previous_tracking_point() next_result = self._get_next_tracking_point() - # Draw motion path - either previous→next OR previous→current + # Draw motion path - either previous→current OR previous→next line_to_draw = None - if prev_result and next_result: - # Draw previous→next line - line_to_draw = ("prev_next", prev_result, next_result) - elif prev_result and self.current_frame in self.tracking_points: - # Draw previous→current line + if prev_result and self.current_frame in self.tracking_points: + # Draw previous→current line (we're on a frame with tracking points) line_to_draw = ("prev_current", prev_result, (self.current_frame, self.tracking_points[self.current_frame])) + elif prev_result and next_result: + # Draw previous→next line (we're between frames) + line_to_draw = ("prev_next", prev_result, next_result) if line_to_draw: line_type, (frame1, pts1), (frame2, pts2) = line_to_draw @@ -2209,16 +2209,16 @@ class VideoEditor: print(f"DEBUG: Line snapping - prev_result: {prev_result}, next_result: {next_result}") - # Determine which line to check: previous→next OR previous→current + # Determine which line to check: previous→current OR previous→next line_to_check = None - if prev_result and next_result: - # Check previous→next line - line_to_check = ("prev_next", prev_result, next_result) - print(f"DEBUG: Checking prev→next line") - elif prev_result and self.current_frame in self.tracking_points: - # Check previous→current line + if prev_result and self.current_frame in self.tracking_points: + # Check previous→current line (we're on a frame with tracking points) line_to_check = ("prev_current", prev_result, (self.current_frame, self.tracking_points[self.current_frame])) - print(f"DEBUG: Checking prev→current line") + print(f"DEBUG: Checking prev->current line") + elif prev_result and next_result: + # Check previous→next line (we're between frames) + line_to_check = ("prev_next", prev_result, next_result) + print(f"DEBUG: Checking prev->next line") if line_to_check: line_type, (frame1, pts1), (frame2, pts2) = line_to_check