Class: Tracksperanto::Export::Equalizer3

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

Overview

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

Constant Summary collapse

HEADER =
'// 3DE Multiple Tracking Curves Export %d x %d * %d frames'

Instance Attribute Summary

Attributes inherited from Base

#io

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#end_tracker_segment, #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



6
7
8
# File 'lib/export/equalizer3.rb', line 6

def self.desc_and_extension
  "3de_v3.txt"
end

.human_nameObject



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

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

Instance Method Details

#end_exportObject



31
32
33
34
35
36
37
# File 'lib/export/equalizer3.rb', line 31

def end_export
  @buffer.rewind
  @io.puts(HEADER % [@w, @h, @highest_keyframe])
  @io.puts(@buffer.read) until @buffer.eof?
  @buffer.close!
  @io.puts("") # Newline at end
end

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



25
26
27
28
29
# File 'lib/export/equalizer3.rb', line 25

def export_point(frame, abs_float_x, abs_float_y, float_residual)
  off_by_one = frame + 1
  @buffer.puts("\t%d\t%.3f\t%.3f" % [off_by_one, abs_float_x, abs_float_y])
  @highest_keyframe = off_by_one if (@highest_keyframe < off_by_one)
end

#start_export(img_width, img_height) ⇒ Object



14
15
16
17
18
19
# File 'lib/export/equalizer3.rb', line 14

def start_export( img_width, img_height)
  @w, @h = img_width, img_height
  # 3DE needs to know the number of keyframes in advance
  @buffer = Tracksperanto::BufferIO.new
  @highest_keyframe = 0
end

#start_tracker_segment(tracker_name) ⇒ Object



21
22
23
# File 'lib/export/equalizer3.rb', line 21

def start_tracker_segment(tracker_name)
  @buffer.puts(tracker_name)
end