tracksperanto 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/DEVELOPER_DOCS.rdoc CHANGED
@@ -46,7 +46,11 @@ Play responsibly.
46
46
  # Create the importer object, for example for a Shake script.
47
47
  # get_importer will give you the good class even you get the capitalization
48
48
  # wrong!
49
- some_importer = Tracksperanto.get_importer("shakescript").new(:width => 1024, :height => 576)
49
+ some_importer = Tracksperanto.get_importer("shakescript").new
50
+
51
+ # This importer needs to know width and height
52
+ some_importer.width = 1024
53
+ some_importer.height = 576
50
54
  some_importer.io = File.open("source_file.fmt")
51
55
 
52
56
  # The importer responds to each() so if your file is not too big you can just load all the trackers
@@ -55,7 +59,8 @@ Play responsibly.
55
59
  trackers = some_importer.to_a
56
60
 
57
61
  # Create the exporter and pass the output file to it
58
- some_exporter = Tracksperanto.get_exporter("flamestabilizer").new(File.open("exported_file.other", "wb"))
62
+ destination_file = File.open("exported_file.other", "wb")
63
+ some_exporter = Tracksperanto.get_exporter("flamestabilizer").new(destination_file)
59
64
 
60
65
  # Now add some middlewares, for example a Scale
61
66
  scaler = Middleware::Scaler.new(some_exporter, :x_factor => 2)
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 2.3.2 / 2011-10-05
2
+
3
+ * Fixed handling of inline comments which are tacked onto the line in in Shake scripts
4
+
1
5
  === 2.3.1 / 2011-08-05
2
6
 
3
7
  * Fixed support for curly braces in Shake scripts
data/Manifest.txt CHANGED
@@ -114,6 +114,7 @@ test/import/samples/pftrack5/apft.2dt
114
114
  test/import/samples/pftrack5/empty_trackers.2dt
115
115
  test/import/samples/pftrack5/garage.2dt
116
116
  test/import/samples/shake_script/REDACTED_shake_file.shk
117
+ test/import/samples/shake_script/comments_inline_with_args.shk
117
118
  test/import/samples/shake_script/designated_global_range_starting_at_negative_frame.shk
118
119
  test/import/samples/shake_script/four_tracks_in_one_matchmove.shk
119
120
  test/import/samples/shake_script/four_tracks_in_one_stabilizer.shk
@@ -18,9 +18,9 @@ module Tracksperanto::ShakeGrammar
18
18
  end
19
19
 
20
20
  def push(atom)
21
- # Send primitive types to parent
22
- return super if !atom.is_a?(Array)
23
- return super if atom[0] != :funcall
21
+
22
+ # Send everything but funcalls to parent
23
+ return super unless atom.is_a?(Array) && atom[0] == :funcall
24
24
 
25
25
  meth_for_shake_func, args = atom[1].downcase, atom[2..-1]
26
26
  if can_handle_meth?(meth_for_shake_func)
@@ -34,6 +34,10 @@ module Tracksperanto::ShakeGrammar
34
34
 
35
35
  private
36
36
 
37
+ # Suppress comment output
38
+ def push_comment
39
+ end
40
+
37
41
  def can_handle_meth?(m)
38
42
  # Ruby 1.9 - match on stringified methname
39
43
  @meths ||= self.class.public_instance_methods(false).map{|mn| mn.to_s }
@@ -22,22 +22,18 @@ module Tracksperanto::ShakeGrammar
22
22
  def initialize(with_io, sentinel = nil, limit_to_one_stmt = false, stack_depth = 0)
23
23
  @io, @stack, @buf, @sentinel, @limit_to_one_stmt, @stack_depth = with_io, [], '', sentinel, limit_to_one_stmt, stack_depth
24
24
  catch(STOP_TOKEN) { parse until @io.eof? }
25
- in_comment? ? consume_comment("\n") : consume_atom!
25
+ @in_comment ? consume_comment! : consume_atom!
26
26
  end
27
27
 
28
28
  private
29
29
 
30
- def in_comment?
31
- (@buf.strip =~ /^\/\//) ? true : false
30
+ def push_comment
31
+ push [:comment, @buf.gsub(/(\s+?)\/\/{1}/, '')]
32
32
  end
33
33
 
34
- def consume_comment(c)
35
- if c == "\n" # Comment
36
- push [:comment, @buf.gsub(/(\s+?)\/\/{1}/, '')]
37
- erase_buffer
38
- else
39
- @buf << c
40
- end
34
+ def consume_comment!
35
+ push_comment
36
+ erase_buffer
41
37
  end
42
38
 
43
39
  def parse
@@ -52,9 +48,18 @@ module Tracksperanto::ShakeGrammar
52
48
  raise WrongInput, "Stack overflow at level #{MAX_STACK_DEPTH}, this is probably a LISP program uploaded by accident"
53
49
  end
54
50
 
55
- return consume_comment(c) if in_comment?
56
-
57
- if !@buf.empty? && (c == "(") # Funcall
51
+ if c == '/' && (@buf[-1].chr rescue nil) == '/' # Comment start
52
+ # If some other data from this line has been accumulated we first consume that
53
+ @buf = @buf[0..-2] # everything except the opening slash of the comment
54
+ consume_atom!
55
+ erase_buffer
56
+ @in_comment = true
57
+ elsif @in_comment && c == "\n" # Comment end
58
+ consume_comment!
59
+ @in_comment = false
60
+ elsif @in_comment
61
+ @buf << c
62
+ elsif !@buf.empty? && (c == "(") # Funcall
58
63
  push([:funcall, @buf.strip] + self.class.new(@io, @sentinel, limit_to_one_stmt = false, @stack_depth + 1).stack)
59
64
  erase_buffer
60
65
  elsif c == '{' # OFX curly braces or a subexpression in a node's knob
@@ -55,15 +55,11 @@ class Tracksperanto::Import::ShakeScript < Tracksperanto::Import::Base
55
55
 
56
56
  # Find whether the passed atom includes a [:trk] on any level
57
57
  def deep_include?(array_or_element, atom_name)
58
- return true if array_or_element == atom_name
59
- if array_or_element.is_a?(Array)
60
- array_or_element.each do | elem |
61
- if elem == atom_name
62
- return true
63
- elsif elem.is_a?(Array)
64
- return true if deep_include?(elem, atom_name)
65
- end
66
- end
58
+ return false unless array_or_element.is_a?(Array)
59
+ return true if array_or_element[0] == atom_name
60
+
61
+ array_or_element.each do | elem |
62
+ return true if deep_include?(elem, atom_name)
67
63
  end
68
64
 
69
65
  false
data/lib/tracksperanto.rb CHANGED
@@ -4,7 +4,7 @@ require 'tempfile'
4
4
 
5
5
  module Tracksperanto
6
6
  PATH = File.expand_path(File.dirname(__FILE__))
7
- VERSION = '2.3.1'
7
+ VERSION = '2.3.2'
8
8
 
9
9
  module Import; end
10
10
  module Export; end
@@ -0,0 +1,50 @@
1
+ // SynthEyes Shake Track Node Exporter V1.0: Z:\data\diablo2\PROJECTS\cstl\324\03_projectfiles\trk\033_001\cstl_324_033_001-trk_v001.sni
2
+ // Last modified: Mon, May 09, 2011 01:26:25 PM
3
+
4
+ SetTimeRange("1-85");
5
+ SetFps(24);
6
+ SetDefaultWidth(1920);
7
+ SetDefaultHeight(1080);
8
+ SetDefaultAspect(1);
9
+ SetDefaultViewerAspect(1);
10
+
11
+ Camera01 = SFileIn("Z:/data/diablo2/PROJECTS/cstl/324/01_plates/cstl_324_033_001/cstl_324_033_001.113764-113848#.dpx", "Auto", 0, 0, "v1.0", "0");
12
+
13
+ Camera01Trackers = Tracker(
14
+ Camera01,
15
+ "1-85", // frame range
16
+ "1/16",
17
+ "luminance",
18
+ 0.75, // reference tolerance
19
+ "use start frame", // reference behavior
20
+ 0.5, // failure tolerance
21
+ "stop", // failure behavior
22
+ 0, // limit processing
23
+ 1, // referenceFrame
24
+ "v2.0", // version
25
+ 0.3, // red weight
26
+ 0.59, // green weight
27
+ 0.11, // blue weight
28
+ 0, // preprocess enable
29
+ 10 // bluramount
30
+ ,
31
+ "Tracker8",
32
+ Linear(0,1727.497@11,1729.391@12,1714.006@13,1696.344@14,1677.673@15,1637.689@16,1584.849@17,1528.008@18,1484.662@19,1472.029@20,1467.682@21,1474.517@22,1494.075@23,1510.224@24,1499.975@25,1472.502@26,1447.493@27,1429.835@28,1404.183@29,1369.445@30,1325.846@31,1278.610@32,1238.860@33,1206.774@34,1182.349@35,1159.561@36,1137.313@37,1111.545@38,1078.042@39,1041.072@40,1005.497@41,978.491@42,954.440@43,929.000@44,898.421@45,873.071@46,856.303@47,837.241@48,809.188@49,783.901@50,756.538@51,730.009@52,706.267@53,684.506@54,667.815@55,651.130@56,631.953@57,610.457@58,593.213@59,576.348@60,556.045@61,531.711@62,506.865@63,488.134@64,465.266@65,443.245@66,418.787@67,399.049@68,380.186@69,373.219@70,371.262@71,383.415@72,405.825@73,406.667@74,408.459@75,400.621@76,383.862@77,353.858@78,317.118@79,298.241@80,290.865@81,291.547@82,287.669@83,290.916@84,295.451@85),
33
+ Linear(0,88.443@11,84.424@12,82.926@13,75.231@14,66.464@15,62.430@16,66.678@17,79.557@18,89.894@19,92.462@20,88.651@21,76.788@22,60.223@23,40.360@24,31.789@25,39.438@26,51.803@27,59.439@28,65.565@29,76.408@30,92.743@31,114.579@32,143.579@33,173.668@34,202.582@35,226.035@36,244.656@37,262.681@38,284.617@39,313.519@40,345.197@41,379.172@42,410.373@43,435.367@44,455.919@45,478.536@46,502.790@47,522.315@48,537.508@49,550.096@50,563.470@51,575.356@52,586.827@53,598.049@54,609.536@55,617.847@56,625.440@57,635.337@58,648.787@59,663.970@60,676.129@61,682.121@62,683.631@63,683.683@64,678.989@65,671.017@66,662.129@67,652.608@68,642.686@69,638.763@70,637.336@71,641.800@72,650.983@73,651.921@74,652.894@75,650.068@76,647.759@77,641.547@78,640.176@79,637.899@80,639.422@81,644.954@82,650.235@83,654.866@84,657.863@85),
34
+
35
+ 1, // Correlation
36
+ -43.200,
37
+ 43.200,
38
+ -43.200,
39
+ 43.200,
40
+ -72.000,
41
+ 72.000,
42
+ -72.000,
43
+ 72.000,
44
+ Linear(0,1727.497@11,1729.391@12,1714.006@13,1696.344@14,1677.673@15,1637.689@16,1584.849@17,1528.008@18,1484.662@19,1472.029@20,1467.682@21,1474.517@22,1494.075@23,1510.224@24,1499.975@25,1472.502@26,1447.493@27,1429.835@28,1404.183@29,1369.445@30,1325.846@31,1278.610@32,1238.860@33,1206.774@34,1182.349@35,1159.561@36,1137.313@37,1111.545@38,1078.042@39,1041.072@40,1005.497@41,978.491@42,954.440@43,929.000@44,898.421@45,873.071@46,856.303@47,837.241@48,809.188@49,783.901@50,756.538@51,730.009@52,706.267@53,684.506@54,667.815@55,651.130@56,631.953@57,610.457@58,593.213@59,576.348@60,556.045@61,531.711@62,506.865@63,488.134@64,465.266@65,443.245@66,418.787@67,399.049@68,380.186@69,373.219@70,371.262@71,383.415@72,405.825@73,406.667@74,408.459@75,400.621@76,383.862@77,353.858@78,317.118@79,298.241@80,290.865@81,291.547@82,287.669@83,290.916@84,295.451@85),
45
+
46
+ Linear(0,88.443@11,84.424@12,82.926@13,75.231@14,66.464@15,62.430@16,66.678@17,79.557@18,89.894@19,92.462@20,88.651@21,76.788@22,60.223@23,40.360@24,31.789@25,39.438@26,51.803@27,59.439@28,65.565@29,76.408@30,92.743@31,114.579@32,143.579@33,173.668@34,202.582@35,226.035@36,244.656@37,262.681@38,284.617@39,313.519@40,345.197@41,379.172@42,410.373@43,435.367@44,455.919@45,478.536@46,502.790@47,522.315@48,537.508@49,550.096@50,563.470@51,575.356@52,586.827@53,598.049@54,609.536@55,617.847@56,625.440@57,635.337@58,648.787@59,663.970@60,676.129@61,682.121@62,683.631@63,683.683@64,678.989@65,671.017@66,662.129@67,652.608@68,642.686@69,638.763@70,637.336@71,641.800@72,650.983@73,651.921@74,652.894@75,650.068@76,647.759@77,641.547@78,640.176@79,637.899@80,639.422@81,644.954@82,650.235@83,654.866@84,657.863@85),
47
+
48
+ 1, // visible
49
+ 1 // enabled
50
+ );
@@ -101,6 +101,26 @@ class ShakeLexerTest < Test::Unit::TestCase
101
101
  s)
102
102
  end
103
103
 
104
+ def test_lexer_with_inline_comments_munged_into_arguments
105
+ st = 'Tracker(
106
+ 0, // preprocess enable
107
+ 10 // bluramount
108
+ ,
109
+ "Tracker8")'
110
+
111
+ s = parse(st)
112
+ assert_equal(
113
+ [[
114
+ :funcall,
115
+ "Tracker",
116
+ 0,
117
+ [:comment, " preprocess enable"],
118
+ 10,
119
+ [:comment, " bluramount"],
120
+ "Tracker8"
121
+ ]],s)
122
+ end
123
+
104
124
  def test_lexer_with_ofx_curly_braces
105
125
  s = parse(File.read(OFX_CURLY_BRACES))
106
126
  assert_equal(
@@ -139,4 +139,11 @@ class ShakeScriptImportTest < Test::Unit::TestCase
139
139
  assert_equal 145, trackers[0].length
140
140
  end
141
141
 
142
+ def test_tracker_node_from_syntheyes
143
+ fixture = File.open(File.dirname(__FILE__) + "/samples/shake_script/comments_inline_with_args.shk")
144
+ trackers = Tracksperanto::Import::ShakeScript.new(:io => fixture, :width => 1920, :height => 1080).to_a
145
+ assert_equal 1, trackers.length
146
+ assert_equal "Camera01Trackers_Tracker8", trackers[0].name
147
+
148
+ end
142
149
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracksperanto
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 1
10
- version: 2.3.1
9
+ - 2
10
+ version: 2.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Julik Tarkhanov
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-08 00:00:00 +02:00
18
+ date: 2011-05-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -192,6 +192,7 @@ files:
192
192
  - test/import/samples/pftrack5/empty_trackers.2dt
193
193
  - test/import/samples/pftrack5/garage.2dt
194
194
  - test/import/samples/shake_script/REDACTED_shake_file.shk
195
+ - test/import/samples/shake_script/comments_inline_with_args.shk
195
196
  - test/import/samples/shake_script/designated_global_range_starting_at_negative_frame.shk
196
197
  - test/import/samples/shake_script/four_tracks_in_one_matchmove.shk
197
198
  - test/import/samples/shake_script/four_tracks_in_one_stabilizer.shk