Class: Tracksperanto::Export::PFTrack4

Inherits:
Base
  • Object
show all
Defined in:
lib/export/pftrack.rb

Overview

Export for PFTrack .2dt files

Constant Summary collapse

KEYFRAME_TEMPLATE =
"%s %.3f %.3f %.3f"
LINEBREAK =

PFtrack wants cross-platform linebreaks

"\r\n"

Instance Attribute Summary

Attributes inherited from Base

#io

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#end_export, inherited, #initialize, #start_export

Methods included from ConstName

#const_name, included

Methods included from SimpleExport

#just_export

Constructor Details

This class inherits a constructor from Tracksperanto::Export::Base

Class Method Details

.desc_and_extensionObject



10
11
12
# File 'lib/export/pftrack.rb', line 10

def self.desc_and_extension
  "pftrack_v4.2dt"
end

.human_nameObject



14
15
16
# File 'lib/export/pftrack.rb', line 14

def self.human_name
  "PFTrack v4 .2dt file"
end

Instance Method Details

#end_tracker_segmentObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/export/pftrack.rb', line 25

def end_tracker_segment
  2.times { @io.write(LINEBREAK) }
  @io.write(@tracker_name.inspect) # autoquotes
  @io.write(LINEBREAK)
  @io.write(@frame_count)
  @io.write(LINEBREAK)
  
  @tracker_io.rewind
  @io.write(@tracker_io.read) until @tracker_io.eof?
  @tracker_io.close!
end

#export_point(frame, abs_float_x, abs_float_y, float_residual) ⇒ Object



37
38
39
40
41
42
# File 'lib/export/pftrack.rb', line 37

def export_point(frame, abs_float_x, abs_float_y, float_residual)
  @frame_count += 1
  line = KEYFRAME_TEMPLATE % [frame, abs_float_x, abs_float_y, float_residual / 8]
  @tracker_io.write(line)
  @tracker_io.write(LINEBREAK)
end

#start_tracker_segment(tracker_name) ⇒ Object



18
19
20
21
22
23
# File 'lib/export/pftrack.rb', line 18

def start_tracker_segment(tracker_name)
  # Setup for the next tracker
  @frame_count = 0
  @tracker_name = tracker_name
  @tracker_io = Tracksperanto::BufferIO.new
end