Sha256: 2a15b5489c96522ae41b786ff500ed0b1bd04d1a2eadfd92bab74152dc9727a7

Contents?: true

Size: 835 Bytes

Versions: 6

Compression:

Stored size: 835 Bytes

Contents

# -*- encoding : utf-8 -*-
# This middleware removes trackers that contain less than min_length keyframes
# from the exported batch
class Tracksperanto::Middleware::LengthCutoff < Tracksperanto::Middleware::Base
  attr_accessor :min_length
  cast_to_int :min_length
  
  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

6 entries across 6 versions & 1 rubygems

Version Path
tracksperanto-2.9.5 lib/middleware/length_cutoff.rb
tracksperanto-2.9.4 lib/middleware/length_cutoff.rb
tracksperanto-2.9.3 lib/middleware/length_cutoff.rb
tracksperanto-2.9.2 lib/middleware/length_cutoff.rb
tracksperanto-2.9.1 lib/middleware/length_cutoff.rb
tracksperanto-2.9.0 lib/middleware/length_cutoff.rb