Sha256: b7818284dd9a356cc7e71803a2564f9cd6714912bdcdb92c0b7782634e56eaf8

Contents?: true

Size: 978 Bytes

Versions: 5

Compression:

Stored size: 978 Bytes

Contents

# This tool removes trackers that contain less than min_length keyframes
# from the exported batch
class Tracksperanto::Tool::LengthCutoff < Tracksperanto::Tool::Base
  
  parameter :min_length, :cast => :int, :desc => "The minimum number of keyframes for the item to contain", :default => 100
  
  def self.action_description
    "Remove trackers that have less than the specified number of keyframes"
  end
  
  def start_tracker_segment(name)
    @tracker = Tracksperanto::Tracker.new(:name => name)
  end
  
  def end_tracker_segment
    return if ((min_length > 0)  && (@tracker.length < min_length))
    
    @exporter.start_tracker_segment(@tracker.name)
    @tracker.each{|kf| @exporter.export_point(kf.frame, kf.abs_x, kf.abs_y, kf.residual) }
    @exporter.end_tracker_segment
  end
  
  def export_point(frame, float_x, float_y, float_residual)
    @tracker.keyframe! :abs_x => float_x, :abs_y => float_y, :residual => float_residual, :frame => frame
  end
  
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tracksperanto-4.2.0 lib/tools/length_cutoff.rb
tracksperanto-4.1.3 lib/tools/length_cutoff.rb
tracksperanto-4.1.2 lib/tools/length_cutoff.rb
tracksperanto-4.1.0 lib/tools/length_cutoff.rb
tracksperanto-4.0.0 lib/tools/length_cutoff.rb