Refactor motion path logic in VideoEditor for clarity
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.
This commit is contained in:
@@ -2033,14 +2033,14 @@ class VideoEditor:
|
|||||||
prev_result = self._get_previous_tracking_point()
|
prev_result = self._get_previous_tracking_point()
|
||||||
next_result = self._get_next_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
|
line_to_draw = None
|
||||||
if prev_result and next_result:
|
if prev_result and self.current_frame in self.tracking_points:
|
||||||
# Draw previous→next line
|
# Draw previous→current line (we're on a frame with tracking points)
|
||||||
line_to_draw = ("prev_next", prev_result, next_result)
|
|
||||||
elif prev_result and self.current_frame in self.tracking_points:
|
|
||||||
# Draw previous→current line
|
|
||||||
line_to_draw = ("prev_current", prev_result, (self.current_frame, self.tracking_points[self.current_frame]))
|
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:
|
if line_to_draw:
|
||||||
line_type, (frame1, pts1), (frame2, pts2) = 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}")
|
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
|
line_to_check = None
|
||||||
if prev_result and next_result:
|
if prev_result and self.current_frame in self.tracking_points:
|
||||||
# Check previous→next line
|
# Check previous→current line (we're on a frame with tracking points)
|
||||||
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
|
|
||||||
line_to_check = ("prev_current", prev_result, (self.current_frame, self.tracking_points[self.current_frame]))
|
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:
|
if line_to_check:
|
||||||
line_type, (frame1, pts1), (frame2, pts2) = line_to_check
|
line_type, (frame1, pts1), (frame2, pts2) = line_to_check
|
||||||
|
Reference in New Issue
Block a user