class Tracksperanto::Tool::MoveToFirst

Sometimes your tracked sequence has been loaded from say frame 73282381, but you want to import into an application that expects the trackers to start at frame 1. This tool autoslips everything so that your trackers start at frame 1.

Public Class Methods

action_description() click to toggle source
# File lib/tools/move_to_first.rb, line 5
def self.action_description
  "Move all the keyframes in time so that the track starts at frame 1"
end

Public Instance Methods

end_export() click to toggle source
# File lib/tools/move_to_first.rb, line 34
def end_export
  actual_start = @start_frames.sort.shift
  
  @exporter.start_export(@width, @height)
  @buf.each do | tracker |
    @exporter.start_tracker_segment(tracker.name)
    tracker.each do | kf |
      @exporter.export_point(kf.frame - actual_start, kf.abs_x, kf.abs_y, kf.residual)
    end
    @exporter.end_tracker_segment
  end
  @exporter.end_export
  
  @buf.clear
end
end_tracker_segment() click to toggle source
# File lib/tools/move_to_first.rb, line 20
def end_tracker_segment
  @buf.push(@current)
  @registered = false
end
export_point(frame, float_x, float_y, float_residual) click to toggle source
# File lib/tools/move_to_first.rb, line 25
def export_point(frame, float_x, float_y, float_residual)
  @current.keyframe!(:frame => frame, :abs_x => float_x, :abs_y => float_y, :residual => float_residual)
  return if @registered
  
  # Note where this tracker starts
  @start_frames.push(frame)
  @registered = true
end
start_export(width, height) click to toggle source
# File lib/tools/move_to_first.rb, line 9
def start_export(width, height)
  @width, @height = width, height
  @start_frames = []
  @buf = Obuf.new
  @registered = false
end
start_tracker_segment(tracker_name) click to toggle source
# File lib/tools/move_to_first.rb, line 16
def start_tracker_segment(tracker_name)
  @current = Tracksperanto::Tracker.new(:name => tracker_name)
end