From fd35c6ac13b5c9f72abc7e7f40e506b19fa9c9c6 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 16 Sep 2025 16:27:11 +0200 Subject: [PATCH] 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. --- croppa/main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/croppa/main.py b/croppa/main.py index 36570ea..10c30b5 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -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