Enhance crop application with motion tracking offset adjustments in VideoEditor

This commit updates the crop functionality to include motion tracking offsets when applying crop adjustments. It ensures that the crop center aligns with tracked positions if motion tracking is enabled, improving the accuracy of cropping during video editing. This enhancement builds on previous updates to motion tracking and crop handling, further refining the user experience.
This commit is contained in:
2025-09-16 16:27:11 +02:00
parent d181644b50
commit fd35c6ac13

View File

@@ -2262,11 +2262,22 @@ class VideoEditor:
original_height, original_width = self.current_display_frame.shape[:2]
available_height = self.window_height - (0 if self.is_image_mode else self.TIMELINE_HEIGHT)
# Step 1: Apply crop (subtract crop offset)
# Step 1: Apply crop (subtract crop offset, including motion tracking offset)
display_x = video_x
display_y = video_y
if self.crop_rect:
crop_x, crop_y, crop_w, crop_h = self.crop_rect
# Apply motion tracking offset if enabled
if self.motion_tracker.tracking_enabled:
current_pos = self.motion_tracker.get_interpolated_position(self.current_frame)
if current_pos:
# Move crop center to tracked point (same logic as in apply_crop_zoom_and_rotation)
tracked_x, tracked_y = current_pos
new_x = int(tracked_x - crop_w // 2)
new_y = int(tracked_y - crop_h // 2)
crop_x, crop_y = new_x, new_y
display_x -= crop_x
display_y -= crop_y