Sha256: 968980b6b70f164cc4c6400f843f94851c1d2e928531c0d8e7110b4329353154

Contents?: true

Size: 907 Bytes

Versions: 7

Compression:

Stored size: 907 Bytes

Contents

class Tracksperanto::Import::Syntheyes < Tracksperanto::Import::Base
  def parse(file_content)
    trackers = []
    file_content.split("\n").each do | line |
      name, frame, x, y, corr = line.split
      
      # Do we already have this tracker?
      t = trackers.find {|e| e.name == name}
      if !t
        t = Tracksperanto::Tracker.new{|t| t.name = name }
        trackers << t
      end
      
      # Add the keyframe
      t.keyframes << Tracksperanto::Keyframe.new do |e| 
        e.frame = frame
        e.abs_x = convert_from_uv(width, x)
        e.abs_y = height - convert_from_uv(height, y) # Convert TL to BL
        e.residual = corr
      end
    end
    
    trackers
  end
  
  private
    def convert_from_uv(absolute_side, uv_value)
      # First, start from zero (-.1 becomes .4)
      value_off_corner = (uv_value.to_f / 2) + 0.5
      absolute_side * value_off_corner
    end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tracksperanto-1.1.1 lib/import/syntheyes.rb
tracksperanto-1.1.0 lib/import/syntheyes.rb
tracksperanto-1.0.6 lib/import/syntheyes.rb
tracksperanto-1.0.4 lib/import/syntheyes.rb
tracksperanto-1.0.2 lib/import/syntheyes.rb
tracksperanto-1.0.1 lib/import/syntheyes.rb
tracksperanto-1.0.0 lib/import/syntheyes.rb