Class: Tracksperanto::Export::PFMatchit

Inherits:
Base
  • Object
show all
Includes:
PFCoords
Defined in:
lib/export/pfmatchit.rb

Overview

Export for PFMatchit

Direct Known Subclasses

PFTrack5

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from Base

#io

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PFCoords

#from_pfcoord, #to_pfcoord

Methods inherited from Base

#end_export, inherited, #initialize

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



9
10
11
# File 'lib/export/pfmatchit.rb', line 9

def self.desc_and_extension
  "pftrack_2011_pfmatchit.txt"
end

.human_nameObject



13
14
15
# File 'lib/export/pfmatchit.rb', line 13

def self.human_name
  "PFTrack2011/PFMatchit .txt file (single camera)"
end

Instance Method Details

#end_tracker_segmentObject

TODO: currently exports to one camera



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/export/pfmatchit.rb', line 30

def end_tracker_segment
  2.times { @io.write(linebreak) }
  @io.write(@tracker_name.inspect) # autoquotes
  @io.write linebreak
  @io.write camera_name # For primary/secondary cam in stereo pair
  @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



44
45
46
47
48
49
# File 'lib/export/pfmatchit.rb', line 44

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

#start_export(w, h) ⇒ Object



17
18
19
20
# File 'lib/export/pfmatchit.rb', line 17

def start_export(w, h)
  @width = w
  @height = h
end

#start_tracker_segment(tracker_name) ⇒ Object



22
23
24
25
26
27
# File 'lib/export/pfmatchit.rb', line 22

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