Class: Tracksperanto::Import::Syntheyes

Inherits:
Base
  • Object
show all
Includes:
UVCoordinates
Defined in:
lib/import/syntheyes.rb

Instance Attribute Summary

Attributes inherited from Base

#height, #io, #progress_block, #width

Class Method Summary collapse

Instance Method Summary collapse

Methods included from UVCoordinates

#absolute_to_uv, #convert_from_uv, #convert_to_uv

Methods inherited from Base

autodetects_size?, distinct_file_ext, inherited, #report_progress

Methods included from BlockInit

#initialize

Methods included from ZipTuples

#zip_curve_tuples

Methods included from ConstName

#const_name

Methods included from Safety

#safe_reader

Methods included from Casts

#cast_to_bool, #cast_to_float, #cast_to_int, #cast_to_string

Class Method Details

.human_nameObject



4
5
6
# File 'lib/import/syntheyes.rb', line 4

def self.human_name
  "Syntheyes \"Tracker 2-D paths\" file"
end

.known_snagsObject



8
9
10
11
12
# File 'lib/import/syntheyes.rb', line 8

def self.known_snags
  "Syntheyes has two formats for exporting tracks. One is called \"Tracker 2-D paths\" in the menu. " +
  "The other is called \"All Tracker Paths\". You told Tracksperanto to treat your file as " +
  "\"Tracker 2-D paths\", if something goes wrong might be a good idea to try the other Tracksperanto input format"
end

Instance Method Details

#each {|@last_tracker| ... } ⇒ Object

Yields:

  • (@last_tracker)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/import/syntheyes.rb', line 14

def each
  @io.each_line do | line |
    name, frame, x, y, frame_status = line.split
    
    # Do we already have this tracker?
    unless @last_tracker && @last_tracker.name == name
      yield(@last_tracker) if @last_tracker
      report_progress("Allocating tracker #{name}")
      @last_tracker = Tracksperanto::Tracker.new{|t| t.name = name }
    end
    
    # Add the keyframe
    k = Tracksperanto::Keyframe.new do |e| 
      e.frame = frame
      e.abs_x = convert_from_uv(x, width)
      e.abs_y = height - convert_from_uv(y, height) # Convert TL to BL
    end
    
    @last_tracker.push(k)
    report_progress("Adding keyframe #{frame} to #{name}")
  end
  
  yield(@last_tracker) if @last_tracker && @last_tracker.any?
  
end