Class: Tracksperanto::Export::Equalizer4

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

Overview

Export for 3DE v4 point files. 3DE always starts frames at 1.

Instance Attribute Summary

Attributes inherited from Base

#io

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from ConstName

#const_name

Methods included from SimpleExport

#just_export

Constructor Details

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

Class Method Details

.desc_and_extensionObject


4
5
6
# File 'lib/export/equalizer4.rb', line 4

def self.desc_and_extension
  "3de_v4.txt"
end

.human_nameObject


8
9
10
# File 'lib/export/equalizer4.rb', line 8

def self.human_name
  "3DE v4 point export .txt file"
end

Instance Method Details

#end_exportObject


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

def end_export
  @internal_io.rewind
  @io.puts(@num_of_trackers)
  @io.puts(@internal_io.read)
  @internal_io.close!
end

#end_tracker_segmentObject


29
30
31
32
33
34
35
# File 'lib/export/equalizer4.rb', line 29

def end_tracker_segment
  @tracker_buffer.rewind
  @internal_io.puts("0") # Color of the point, 0 is red
  @internal_io.puts(@num_of_kfs)
  @internal_io.puts(@tracker_buffer.read)
  @tracker_buffer.close!
end

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


24
25
26
27
# File 'lib/export/equalizer4.rb', line 24

def export_point(frame, abs_float_x, abs_float_y, float_residual)
  @tracker_buffer.puts("%d %.15f %.15f" % [frame + 1, abs_float_x, abs_float_y])
  @num_of_kfs += 1
end

#start_export(img_width, img_height) ⇒ Object


12
13
14
15
16
# File 'lib/export/equalizer4.rb', line 12

def start_export( img_width, img_height)
  # 3DE needs to know the number of points in advance,
  # so we will just buffer to a StringIO
  @internal_io, @num_of_trackers = Tracksperanto::BufferIO.new, 0
end

#start_tracker_segment(tracker_name) ⇒ Object


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

def start_tracker_segment(tracker_name)
  @internal_io.puts(tracker_name)
  @num_of_trackers += 1
  @tracker_buffer, @num_of_kfs = Tracksperanto::BufferIO.new, 0
end