Enhance VideoEditor and MotionTracker with improved logging and crop handling
This commit adds detailed logging to the VideoEditor and MotionTracker classes, providing insights into the transformations and adjustments made during point processing and cropping. It refines the crop position adjustment logic to ensure offsets are only applied when necessary and enhances the visibility of tracking points based on their position relative to the crop area. Additionally, it improves the handling of motion tracking toggling, ensuring a default crop rect is created when needed, thus enhancing the overall user experience during video editing.
This commit is contained in:
@@ -108,11 +108,20 @@ class MotionTracker:
|
||||
|
||||
def get_tracking_offset(self, frame_number: int) -> Tuple[float, float]:
|
||||
"""Get the offset to center the crop on the tracked point"""
|
||||
if not self.tracking_enabled or not self.base_zoom_center:
|
||||
import logging
|
||||
logger = logging.getLogger('croppa')
|
||||
|
||||
if not self.tracking_enabled:
|
||||
print(f"get_tracking_offset: tracking not enabled, returning (0,0)")
|
||||
return (0.0, 0.0)
|
||||
|
||||
if not self.base_zoom_center:
|
||||
print(f"get_tracking_offset: no base_zoom_center, returning (0,0)")
|
||||
return (0.0, 0.0)
|
||||
|
||||
current_pos = self.get_interpolated_position(frame_number)
|
||||
if not current_pos:
|
||||
print(f"get_tracking_offset: no interpolated position for frame {frame_number}, returning (0,0)")
|
||||
return (0.0, 0.0)
|
||||
|
||||
# Calculate offset to center the crop on the tracked point
|
||||
@@ -120,6 +129,7 @@ class MotionTracker:
|
||||
offset_x = current_pos[0] - self.base_zoom_center[0]
|
||||
offset_y = current_pos[1] - self.base_zoom_center[1]
|
||||
|
||||
print(f"get_tracking_offset: frame={frame_number}, base={self.base_zoom_center}, current={current_pos}, offset=({offset_x}, {offset_y})")
|
||||
return (offset_x, offset_y)
|
||||
|
||||
def start_tracking(self, base_crop_rect: Tuple[int, int, int, int], base_zoom_center: Tuple[int, int]):
|
||||
|
||||
Reference in New Issue
Block a user