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



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

def self.desc_and_extension
  "3de_v3.txt"
end

.human_nameObject



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

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

Instance Method Details

#end_exportObject



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

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



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

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



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

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



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

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