Finally reinvent the whole mapping procedure again!
This commit is contained in:
@@ -1248,9 +1248,21 @@ class VideoEditor:
|
|||||||
# This handles all transformations (crop, zoom, rotation) correctly
|
# This handles all transformations (crop, zoom, rotation) correctly
|
||||||
display_frame = self.apply_crop_zoom_and_rotation(self.current_display_frame)
|
display_frame = self.apply_crop_zoom_and_rotation(self.current_display_frame)
|
||||||
if display_frame is not None:
|
if display_frame is not None:
|
||||||
# Store features in rotated frame coordinates (like existing motion tracking)
|
# Map coordinates from transformed frame to rotated frame coordinates
|
||||||
|
# Use the existing coordinate transformation system
|
||||||
def coord_mapper(x, y):
|
def coord_mapper(x, y):
|
||||||
return (int(x), int(y))
|
# Map from transformed frame coordinates to screen coordinates
|
||||||
|
frame_height, frame_width = display_frame.shape[:2]
|
||||||
|
available_height = self.window_height - (0 if self.is_image_mode else self.TIMELINE_HEIGHT)
|
||||||
|
start_y = (available_height - frame_height) // 2
|
||||||
|
start_x = (self.window_width - frame_width) // 2
|
||||||
|
|
||||||
|
# Convert to screen coordinates
|
||||||
|
screen_x = x + start_x
|
||||||
|
screen_y = y + start_y
|
||||||
|
|
||||||
|
# Use the existing coordinate transformation system
|
||||||
|
return self._map_screen_to_rotated(screen_x, screen_y)
|
||||||
|
|
||||||
self.feature_tracker.extract_features(display_frame, self.current_frame, coord_mapper)
|
self.feature_tracker.extract_features(display_frame, self.current_frame, coord_mapper)
|
||||||
|
|
||||||
@@ -2676,6 +2688,9 @@ class VideoEditor:
|
|||||||
self.tracking_enabled = False
|
self.tracking_enabled = False
|
||||||
self.tracking_points = {}
|
self.tracking_points = {}
|
||||||
|
|
||||||
|
# Reset feature tracking
|
||||||
|
self.feature_tracker.clear_features()
|
||||||
|
|
||||||
# Reset cut markers
|
# Reset cut markers
|
||||||
self.cut_start_frame = None
|
self.cut_start_frame = None
|
||||||
self.cut_end_frame = None
|
self.cut_end_frame = None
|
||||||
@@ -3561,13 +3576,26 @@ class VideoEditor:
|
|||||||
# This handles all transformations (crop, zoom, rotation) correctly
|
# This handles all transformations (crop, zoom, rotation) correctly
|
||||||
display_frame = self.apply_crop_zoom_and_rotation(self.current_display_frame)
|
display_frame = self.apply_crop_zoom_and_rotation(self.current_display_frame)
|
||||||
if display_frame is not None:
|
if display_frame is not None:
|
||||||
# Store features in rotated frame coordinates (like existing motion tracking)
|
# Map coordinates from transformed frame to rotated frame coordinates
|
||||||
# This way we can reuse the existing display system
|
# Use the existing coordinate transformation system
|
||||||
def coord_mapper(x, y):
|
def coord_mapper(x, y):
|
||||||
# The transformed frame coordinates are already in the right space
|
# The transformed frame coordinates are in the display frame space
|
||||||
# We just need to map them to rotated frame coordinates
|
# We need to map them to screen coordinates first, then use the existing
|
||||||
# Since the transformed frame is what the user sees, we can use it directly
|
# _map_screen_to_rotated function
|
||||||
return (int(x), int(y))
|
|
||||||
|
# Map from transformed frame coordinates to screen coordinates
|
||||||
|
# The transformed frame is centered on the canvas
|
||||||
|
frame_height, frame_width = display_frame.shape[:2]
|
||||||
|
available_height = self.window_height - (0 if self.is_image_mode else self.TIMELINE_HEIGHT)
|
||||||
|
start_y = (available_height - frame_height) // 2
|
||||||
|
start_x = (self.window_width - frame_width) // 2
|
||||||
|
|
||||||
|
# Convert to screen coordinates
|
||||||
|
screen_x = x + start_x
|
||||||
|
screen_y = y + start_y
|
||||||
|
|
||||||
|
# Use the existing coordinate transformation system
|
||||||
|
return self._map_screen_to_rotated(screen_x, screen_y)
|
||||||
|
|
||||||
success = self.feature_tracker.extract_features(display_frame, self.current_frame, coord_mapper)
|
success = self.feature_tracker.extract_features(display_frame, self.current_frame, coord_mapper)
|
||||||
if success:
|
if success:
|
||||||
|
|||||||
Reference in New Issue
Block a user