tracksperanto 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/.DS_Store +0 -0
  2. data/History.txt +11 -0
  3. data/Manifest.txt +64 -20
  4. data/README.txt +82 -30
  5. data/Rakefile +1 -0
  6. data/bin/tracksperanto +21 -14
  7. data/lib/export/base.rb +16 -6
  8. data/lib/export/match_mover.rb +40 -0
  9. data/lib/export/nuke_script.rb +78 -0
  10. data/lib/export/pftrack.rb +14 -14
  11. data/lib/export/shake_text.rb +7 -8
  12. data/lib/export/syntheyes.rb +9 -5
  13. data/lib/import/base.rb +45 -12
  14. data/lib/import/flame_stabilizer.rb +17 -32
  15. data/lib/import/match_mover.rb +65 -0
  16. data/lib/import/nuke_script.rb +96 -0
  17. data/lib/import/pftrack.rb +9 -2
  18. data/lib/import/shake_grammar/catcher.rb +56 -0
  19. data/lib/import/shake_grammar/lexer.rb +95 -0
  20. data/lib/import/shake_script.rb +189 -103
  21. data/lib/import/shake_text.rb +5 -3
  22. data/lib/import/syntheyes.rb +9 -2
  23. data/lib/middleware/base.rb +6 -1
  24. data/lib/middleware/golden.rb +7 -0
  25. data/lib/middleware/reformat.rb +10 -3
  26. data/lib/middleware/scaler.rb +14 -4
  27. data/lib/middleware/shift.rb +10 -0
  28. data/lib/middleware/slipper.rb +3 -0
  29. data/lib/pipeline/base.rb +111 -37
  30. data/lib/tracksperanto/block_init.rb +7 -0
  31. data/lib/tracksperanto/casts.rb +31 -0
  32. data/lib/tracksperanto/format_detector.rb +35 -0
  33. data/lib/tracksperanto/keyframe.rb +31 -0
  34. data/lib/tracksperanto/safety.rb +20 -0
  35. data/lib/tracksperanto/tracker.rb +38 -0
  36. data/lib/tracksperanto/zip_tuples.rb +20 -0
  37. data/lib/tracksperanto.rb +13 -100
  38. data/test/.DS_Store +0 -0
  39. data/test/export/.DS_Store +0 -0
  40. data/test/export/README_EXPORT_TESTS.txt +15 -0
  41. data/test/export/samples/ref_NukeScript.nk +25 -0
  42. data/test/export/samples/ref_NukeScript.nk.autosave +77 -0
  43. data/test/export/samples/ref_PFTrack.2dt +50 -0
  44. data/test/export/samples/ref_ShakeText.txt +48 -0
  45. data/test/export/samples/ref_Syntheyes.txt +42 -0
  46. data/test/export/samples/ref_matchmover.rz2 +52 -0
  47. data/test/export/test_match_mover_export.rb +16 -0
  48. data/test/export/test_mux.rb +23 -0
  49. data/test/export/test_nuke_export.rb +22 -0
  50. data/test/export/test_pftrack_export.rb +19 -0
  51. data/test/export/test_shake_export.rb +15 -0
  52. data/test/export/test_syntheyes_export.rb +15 -0
  53. data/test/helper.rb +85 -2
  54. data/test/import/.DS_Store +0 -0
  55. data/test/{samples → import/samples}/.DS_Store +0 -0
  56. data/test/{samples → import/samples}/flyover2DP_syntheyes.txt +0 -0
  57. data/test/import/samples/four_tracks_in_one_matchmove.shk +323 -0
  58. data/test/import/samples/four_tracks_in_one_stabilizer.shk +321 -0
  59. data/test/{samples → import/samples}/fromCombustion_fromMidClip_wSnap.stabilizer +0 -0
  60. data/test/{samples → import/samples}/hugeFlameSetup.stabilizer +0 -0
  61. data/test/import/samples/kipPointsMatchmover.rz2 +523 -0
  62. data/test/{samples → import/samples}/megaTrack.action.3dtrack.stabilizer +0 -0
  63. data/test/{samples → import/samples}/one_shake_tracker.txt +0 -0
  64. data/test/{samples → import/samples}/one_shake_tracker_from_first.txt +0 -0
  65. data/test/import/samples/one_tracker_with_break.nk +71 -0
  66. data/test/import/samples/one_tracker_with_break_in_grp.nk +91 -0
  67. data/test/{samples → import/samples}/shake_tracker_nodes.shk +0 -0
  68. data/test/{samples → import/samples}/shake_tracker_nodes_to_syntheyes.txt +0 -0
  69. data/test/{samples → import/samples}/sourcefile_pftrack.2dt +0 -0
  70. data/test/{samples → import/samples}/three_tracks_in_one_stabilizer.shk +0 -0
  71. data/test/{samples → import/samples}/two_shake_trackers.txt +0 -0
  72. data/test/{samples → import/samples}/two_tracks_in_one_tracker.shk +0 -0
  73. data/test/{test_flame_import.rb → import/test_flame_import.rb} +15 -9
  74. data/test/import/test_match_mover_import.rb +44 -0
  75. data/test/import/test_nuke_import.rb +63 -0
  76. data/test/{test_pftrack_import.rb → import/test_pftrack_import.rb} +10 -4
  77. data/test/import/test_shake_catcher.rb +72 -0
  78. data/test/import/test_shake_lexer.rb +95 -0
  79. data/test/import/test_shake_script_import.rb +75 -0
  80. data/test/{test_shake_text_import.rb → import/test_shake_text_import.rb} +10 -3
  81. data/test/{test_syntheyes_import.rb → import/test_syntheyes_import.rb} +8 -3
  82. data/test/middleware/test_golden_middleware.rb +32 -0
  83. data/test/middleware/test_reformat_middleware.rb +35 -0
  84. data/test/middleware/test_scaler_middleware.rb +51 -0
  85. data/test/middleware/test_shift_middleware.rb +26 -0
  86. data/test/middleware/test_slip_middleware.rb +31 -0
  87. data/test/pipeline/test_pipeline_base.rb +14 -0
  88. data/test/test_format_detector.rb +39 -0
  89. data/test/test_tracker.rb +48 -0
  90. data/tracksperanto.gemspec +9 -7
  91. metadata +101 -30
  92. data/lib/middleware/close.rb +0 -6
  93. data/test/test_shake_export.rb +0 -58
  94. data/test/test_shake_script_import.rb +0 -50
@@ -0,0 +1,91 @@
1
+ #! /Applications/Nuke5.1v2/Nuke5.1v2.app/Contents/MacOS/Nuke5.1v2 -nx
2
+ version 5.1200
3
+ define_window_layout_xml {<?xml version="1.0" encoding="UTF-8"?>
4
+ <layout version="1.0">
5
+ <window x="214" y="133" w="1680" h="1024" screen="0">
6
+ <splitter orientation="1">
7
+ <split size="1062"></split>
8
+ <splitter orientation="1">
9
+ <split size="40"></split>
10
+ <dock id="" hideTitles="1" activePageId="Toolbar.1">
11
+ <page id="Toolbar.1"></page>
12
+ </dock>
13
+ <split size="1018"></split>
14
+ <splitter orientation="2">
15
+ <split size="499"></split>
16
+ <dock id="" activePageId="Viewer.1">
17
+ <page id="Viewer.1"></page>
18
+ </dock>
19
+ <split size="499"></split>
20
+ <dock id="" activePageId="DAG.1">
21
+ <page id="DAG.1"></page>
22
+ <page id="Curve Editor.1"></page>
23
+ <page id="DAG.2"></page>
24
+ </dock>
25
+ </splitter>
26
+ </splitter>
27
+ <split size="614"></split>
28
+ <dock id="" activePageId="Properties.1">
29
+ <page id="Properties.1"></page>
30
+ </dock>
31
+ </splitter>
32
+ </window>
33
+ </layout>
34
+ }
35
+ Root {
36
+ inputs 0
37
+ name /Code/apps/tracksperanto/test/samples/one_tracker_with_break_in_grp.nk
38
+ frame 763
39
+ last_frame 1580
40
+ lock_range true
41
+ format "640 480 0 0 640 480 1 PC_Video"
42
+ proxy_type scale
43
+ proxy_format "640 480 0 0 640 480 1 PC_Video"
44
+ }
45
+ Read {
46
+ inputs 0
47
+ file /Users/julik/Desktop/Storm/E036/E036_L005.%04d.dpx
48
+ format "2048 1176 0 0 2048 1176 1 "
49
+ last 1580
50
+ timecode 03:38:32:07
51
+ edge_code "02 05 17 3388 6703 60"
52
+ name Read1
53
+ xpos -271
54
+ ypos -195
55
+ }
56
+ Group {
57
+ name Group1
58
+ selected true
59
+ xpos -171
60
+ ypos -93
61
+ }
62
+ Input {
63
+ inputs 0
64
+ name Input1
65
+ xpos -227
66
+ ypos -113
67
+ }
68
+ Tracker3 {
69
+ track1 {{curve x742 888 890.2463989 891.6602783 893.5056763 895.6155396 s95 897.2791748 899.1762695 901.6463623 903.6976318 905.1331177 907.3597412 909.7727051 912.0731812 913.7190552 916.0959473 918.1025391 920.0751953 922.1898804 924.6269531 926.2683716 928.2131348 930.7736206} {curve x742 406 405.3980103 404.867981 404.1585083 403.6867065 403.1013489 402.463623 401.933136 401.3148499 400.4875183 399.8830566 399.3424377 398.5214233 398.1871033 397.5262756 396.8475647 396.2599182 395.5371399 395.1407166 394.3450928 393.7192078 392.8123474}}
70
+ enable2 true
71
+ track2 {{curve i x742 1105 1107.277466 1108.645996 1110.494629 1112.658691 1114.258179 1116.237061 1118.607788 1120.709717 1122.134155 1124.373779 1126.885132 1129.21936 1130.868164 1133.252686 1135.243896 1137.268188 1139.385376 1141.824097 1143.422974 1145.289551 1147.972412} {curve i x742 524 523.3273926 522.723999 521.8934326 521.4053955 520.6884766 520.0819092 519.5550537 518.897644 518.0953369 517.442688 516.8226929 516.0817871 515.673584 515.0698853 514.3513184 513.664917 512.9036865 512.5012817 511.5973511 510.9969482 510.1079407}}
72
+ translate {{curve i x742 0 2.246398926 3.66027832 5.50567627 7.615539551 9.279174805 11.17626953 13.6463623 15.69763184 17.13311768 19.35974121 21.77270508 24.07318115 25.71905518 28.09594727 30.10253906 32.07519531 34.18988037 36.62695312 38.26837158 40.21313477 42.77362061} {curve i x742 0 -0.6019897461 -1.132019043 -1.841491699 -2.313293457 -2.898651123 -3.536376953 -4.066864014 -4.685150146 -5.512481689 -6.116943359 -6.657562256 -7.47857666 -7.812896729 -8.473724365 -9.152435303 -9.740081787 -10.46286011 -10.85928345 -11.65490723 -12.28079224 -13.18765259}}
73
+ center {{curve i x742 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888} {curve i x742 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406}}
74
+ name Tracker1
75
+ xpos -227
76
+ ypos -73
77
+ }
78
+ Output {
79
+ name Output1
80
+ xpos -227
81
+ ypos 27
82
+ }
83
+ end_group
84
+ push 0
85
+ Viewer {
86
+ inputs 2
87
+ frame 763
88
+ name Viewer1
89
+ xpos -271
90
+ ypos -6
91
+ }
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.dirname(__FILE__) + '/../helper'
2
2
 
3
3
  class FlameImportTest < Test::Unit::TestCase
4
4
  DELTA = 0.1
@@ -73,18 +73,18 @@ class FlameImportTest < Test::Unit::TestCase
73
73
  assert_equal 5, c.length
74
74
 
75
75
  first_key = c[0]
76
- assert_in_delta 0.0, first_key.value, DELTA
77
- assert_equal 0, first_key.frame
76
+ assert_in_delta 0.0, first_key[1], DELTA
77
+ assert_equal 0, first_key[0]
78
78
 
79
79
  key_four = c[4]
80
80
  assert_not_nil key_four, "The last keyframe should not be nil"
81
81
 
82
- assert_in_delta -246.951, key_four.value, DELTA
83
- assert_equal 115, key_four.frame
82
+ assert_in_delta -246.951, key_four[1], DELTA
83
+ assert_equal 115, key_four[0]
84
84
  end
85
85
 
86
86
  def test_parsing_from_flame
87
- fixture = File.read(File.dirname(__FILE__) + '/samples/hugeFlameSetup.stabilizer')
87
+ fixture = File.open(File.dirname(__FILE__) + '/samples/hugeFlameSetup.stabilizer')
88
88
 
89
89
  parser = Tracksperanto::Import::FlameStabilizer.new
90
90
 
@@ -105,9 +105,15 @@ class FlameImportTest < Test::Unit::TestCase
105
105
  assert_in_delta 771.58, first_k.abs_x, DELTA
106
106
  assert_in_delta 107.98192, first_k.abs_y, DELTA
107
107
  end
108
-
108
+
109
+ def test_introspects_properly
110
+ i = Tracksperanto::Import::FlameStabilizer
111
+ assert_equal "Flame .stabilizer file", i.human_name
112
+ assert i.autodetects_size?
113
+ end
114
+
109
115
  def test_parsing_another_track
110
- fixture = File.read(File.dirname(__FILE__) + '/samples/megaTrack.action.3dtrack.stabilizer')
116
+ fixture = File.open(File.dirname(__FILE__) + '/samples/megaTrack.action.3dtrack.stabilizer')
111
117
 
112
118
  parser = Tracksperanto::Import::FlameStabilizer.new
113
119
 
@@ -119,7 +125,7 @@ class FlameImportTest < Test::Unit::TestCase
119
125
  end
120
126
 
121
127
  def test_simple_from_combustion
122
- fixture = File.read(File.dirname(__FILE__) + '/samples/fromCombustion_fromMidClip_wSnap.stabilizer')
128
+ fixture = File.open(File.dirname(__FILE__) + '/samples/fromCombustion_fromMidClip_wSnap.stabilizer')
123
129
 
124
130
  parser = Tracksperanto::Import::FlameStabilizer.new
125
131
 
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../helper'
2
+
3
+ class MatchMoverImportTest < Test::Unit::TestCase
4
+ DELTA = 0.01
5
+
6
+ P = File.dirname(__FILE__) + '/samples/kipPointsMatchmover.rz2'
7
+
8
+ def test_introspects_properly
9
+ i = Tracksperanto::Import::MatchMover
10
+ assert_equal "MatchMover .rz2 file", i.human_name
11
+ assert i.autodetects_size?
12
+ end
13
+
14
+ def test_parsing_from_matchmover
15
+ fixture = File.open(P)
16
+
17
+ parser = Tracksperanto::Import::MatchMover.new
18
+ parser.width = 2048
19
+ parser.height = 1176
20
+
21
+ trackers = parser.parse(fixture)
22
+ assert_equal 2560, parser.width
23
+ assert_equal 1080, parser.height
24
+
25
+ assert_equal 5, trackers.length
26
+
27
+ first_t = trackers[0]
28
+ assert_equal "Track 01", first_t.name
29
+ assert_equal 131, first_t.length
30
+ first_kf = first_t[0]
31
+
32
+ assert_equal 0, first_kf.frame
33
+ assert_in_delta 649.523, first_kf.abs_x, DELTA
34
+ assert_in_delta 423.929, first_kf.abs_y, DELTA
35
+ assert_in_delta 0.2, first_kf.residual, DELTA
36
+
37
+ last_kf = first_t[-1]
38
+ assert_equal 130, last_kf.frame
39
+ assert_in_delta 603.148, last_kf.abs_x, DELTA
40
+ assert_in_delta 728.46, last_kf.abs_y, DELTA
41
+ assert_in_delta 0.027457, last_kf.residual, DELTA
42
+ end
43
+
44
+ end
@@ -0,0 +1,63 @@
1
+ require File.dirname(__FILE__) + '/../helper'
2
+
3
+ class NukeImportTest < Test::Unit::TestCase
4
+ DELTA = 0.1
5
+
6
+ def test_introspects_properly
7
+ i = Tracksperanto::Import::NukeScript
8
+ assert_equal "Nuke .nk script file", i.human_name
9
+ assert !i.autodetects_size?
10
+ end
11
+
12
+ def test_parsing_from_nuke
13
+ fixture = File.open(File.dirname(__FILE__) + '/samples/one_tracker_with_break.nk')
14
+
15
+ parser = Tracksperanto::Import::NukeScript.new
16
+ parser.width = 2048
17
+ parser.height = 1176
18
+
19
+ trackers = parser.parse(fixture)
20
+
21
+ assert_equal 2, trackers.length
22
+ sec_tracker = trackers[1]
23
+ assert_equal 22, sec_tracker.keyframes.length
24
+ assert_equal 762, sec_tracker.keyframes[-1].frame
25
+ assert_in_delta 1147.972, sec_tracker.keyframes[-1].abs_x, DELTA
26
+ assert_in_delta 510.107, sec_tracker.keyframes[-1].abs_y, DELTA
27
+ end
28
+
29
+ def test_parsing_from_nuke_group
30
+ fixture = File.open(File.dirname(__FILE__) + '/samples/one_tracker_with_break_in_grp.nk')
31
+
32
+ parser = Tracksperanto::Import::NukeScript.new
33
+ parser.width = 2048
34
+ parser.height = 1176
35
+
36
+ trackers = parser.parse(fixture)
37
+ assert_equal 2, trackers.length
38
+
39
+ sec_tracker = trackers[1]
40
+ assert_equal 22, sec_tracker.keyframes.length
41
+ assert_equal 762, sec_tracker.keyframes[-1].frame
42
+ assert_in_delta 1147.972, sec_tracker.keyframes[-1].abs_x, DELTA
43
+ assert_in_delta 510.107, sec_tracker.keyframes[-1].abs_y, DELTA
44
+ end
45
+
46
+ def test_parsing_nuke_curve
47
+ curve = '{curve x742 888 890.2463989 891.6602783 \
48
+ 893.5056763 895.6155396 s95 897.2791748 899.1762695 x754 912.0731812 x755 913.7190552 916.0959473 918.1025391 920.0751953 922.1898804}'
49
+ p = Tracksperanto::Import::NukeScript.new
50
+ result = p.send(:parse_curve, curve)
51
+ assert_kind_of Array, result
52
+ assert_equal 13, result.length
53
+ assert_equal 742, result[0][0]
54
+ assert_equal 754, result[7][0]
55
+ end
56
+
57
+ def test_zip_channels
58
+ tuples_x = [[1, 125], [3, 234], [5, 456], [9,876]]
59
+ tuples_y = [[2, 437], [3, 123], [6, 432], [9, 430]]
60
+ result = Tracksperanto::Import::NukeScript.new.send(:zip_curve_tuples, tuples_x, tuples_y)
61
+ assert_equal [[3, 234, 123], [9, 876, 430]], result
62
+ end
63
+ end
@@ -1,10 +1,16 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.dirname(__FILE__) + '/../helper'
2
2
 
3
- class SyntheyesImportTest < Test::Unit::TestCase
3
+ class PFTrackImportTest < Test::Unit::TestCase
4
4
  DELTA = 0.1
5
5
 
6
+ def test_introspects_properly
7
+ i = Tracksperanto::Import::PFTrack
8
+ assert_equal "PFTrack .2dt file", i.human_name
9
+ assert !i.autodetects_size?
10
+ end
11
+
6
12
  def test_parsing_from_importable
7
- fixture = File.read(File.dirname(__FILE__) + '/samples/sourcefile_pftrack.2dt')
13
+ fixture = File.open(File.dirname(__FILE__) + '/samples/sourcefile_pftrack.2dt')
8
14
 
9
15
  parser = Tracksperanto::Import::PFTrack.new
10
16
  parser.width = 2560
@@ -28,6 +34,6 @@ class SyntheyesImportTest < Test::Unit::TestCase
28
34
  assert_in_delta 729.330, last_kf.abs_x, DELTA
29
35
 
30
36
  assert_equal "Tracker41", trackers[-1].name
31
- assert_equal 467, tracker[-1].name
37
+ assert_equal 467, trackers[-1].keyframes.length
32
38
  end
33
39
  end
@@ -0,0 +1,72 @@
1
+ require File.dirname(__FILE__) + '/../helper'
2
+
3
+ class ShakeCatcherTest < Test::Unit::TestCase
4
+ C = Tracksperanto::ShakeGrammar::Catcher
5
+
6
+ def test_hould_catch_simple_funcall
7
+ k = Class.new(C) do
8
+ def foofunc(a, b, c)
9
+ "#{a.inspect} #{b.inspect} #{c.inspect}"
10
+ end
11
+ end
12
+ tree = parse("FooFunc(1, 2, 3)", k)
13
+ assert_equal [[:retval, "1 2 3"]], tree
14
+ end
15
+
16
+ def test_uknown_funcalls
17
+ k = Class.new(C)
18
+ tree = parse("OuterFunc(InnerFunc(15)", k)
19
+ assert_equal [:unknown_func], tree
20
+
21
+ tree = parse("OuterFunc(15);", k)
22
+ assert_equal [:unknown_func], tree
23
+ end
24
+
25
+ def test_nested_funcalls
26
+ k = Class.new(C) do
27
+ def outerfunc(a)
28
+ a * 2
29
+ end
30
+
31
+ def innerfunc(b)
32
+ b * 10
33
+ end
34
+ end
35
+
36
+ tree = parse("OuterFunc(InnerFunc(15)", k)
37
+ assert_equal [[:retval, 300]], tree
38
+ end
39
+
40
+ def test_linear_funcall
41
+ k = Class.new(C) do
42
+ def linear(first_arg, *keyframes)
43
+ keyframes.map do | kf |
44
+ [kf[0][1], kf[1][1]]
45
+ end
46
+ end
47
+ end
48
+
49
+ tree = parse('Linear(0,591.702@1,591.452@2,591.202@3,590.733@4,590.202@5,589.421@6,589.249@7)', k)
50
+ assert_equal [[:retval, [[591.702, 1], [591.452, 2], [591.202, 3], [590.733, 4], [590.202, 5], [589.421, 6], [589.249, 7]]]], tree
51
+ end
52
+
53
+ def test_nested_funcalls_with_array_return
54
+ k = Class.new(C) do
55
+ def outerfunc(a)
56
+ a * 2
57
+ end
58
+
59
+ def innerfunc(b)
60
+ [b, b* 2, b* 3]
61
+ end
62
+ end
63
+
64
+ tree = parse("OuterFunc(InnerFunc(15)", k)
65
+ assert_equal [[:retval, [15, 30, 45, 15, 30, 45]]], tree
66
+ end
67
+
68
+ def parse(s, klass)
69
+ s = StringIO.new(s) unless s.respond_to?(:read)
70
+ klass.new(s).stack
71
+ end
72
+ end
@@ -0,0 +1,95 @@
1
+ require File.dirname(__FILE__) + '/../helper'
2
+
3
+ class ShakeLexerTest < Test::Unit::TestCase
4
+ P = File.dirname(__FILE__) + "/samples/shake_tracker_nodes.shk"
5
+ L = Tracksperanto::ShakeGrammar::Lexer
6
+
7
+ def test_parse_single_cmt
8
+ cmt = " // Mary had a little lamb"
9
+ s = parse(cmt)
10
+ assert_equal [[:comment, " Mary had a little lamb"]], s
11
+ end
12
+
13
+ def test_parse_two_line_cmt
14
+ cmt = [" // Mary had a little lamb", " // Old McDonald had a farm"].join("\n\n\n\n\n\n")
15
+ s = parse(cmt)
16
+ assert_equal [[:comment, " Mary had a little lamb"], [:comment, " Old McDonald had a farm"]], s
17
+ end
18
+
19
+ def test_parse_cmt_and_unknown
20
+ cmt = " // Mary had a little lamb\nFooBar"
21
+ s = parse(cmt)
22
+ assert_equal [[:comment, " Mary had a little lamb"], [:atom, "FooBar"]], s
23
+ end
24
+
25
+ def test_parse_funcall
26
+ s = parse ' DoFoo(1, 2, 3, "Welcome!\"\""); '
27
+ assert_equal [[:funcall, "DoFoo", [:atom_i, 1], [:atom_i, 2], [:atom_i, 3], [:atom_c, 'Welcome!""']]], s
28
+ end
29
+
30
+ def test_parse_nested_funcall
31
+ s = parse ' DoFoo(1, Foo(4));'
32
+ assert_equal [[:funcall, "DoFoo", [:atom_i, 1], [:funcall, "Foo", [:atom_i, 4]]]], s
33
+ end
34
+
35
+ def test_parse_single_nested_funcall
36
+ s = parse("OuterFunc(InnerFunc(15)")
37
+ assert_equal [[:funcall, "OuterFunc", [:funcall, "InnerFunc", [:atom_i, 15]]]], s
38
+ end
39
+
40
+ def test_parse_single_funcall
41
+ s = parse('SomeFunc(1,2,3)')
42
+ assert_equal [[:funcall, "SomeFunc", [:atom_i, 1], [:atom_i, 2], [:atom_i, 3]]], s
43
+ end
44
+
45
+ def test_parse_funcall_with_valueats
46
+ s = parse 'Linear(0,716.08@1,715.846@2,715.518@3,715.034@4,714.377@5)'
47
+ assert_equal(
48
+ [
49
+ [:funcall, "Linear", [:atom_i, 0],
50
+ [[:atom_f, 716.08], [:atom_at_i, 1]],
51
+ [[:atom_f, 715.846], [:atom_at_i, 2]],
52
+ [[:atom_f, 715.518], [:atom_at_i, 3]],
53
+ [[:atom_f, 715.034], [:atom_at_i, 4]],
54
+ [[:atom_f, 714.377], [:atom_at_i, 5]]
55
+ ]
56
+ ],
57
+ s)
58
+ end
59
+
60
+ def test_parse_hermite_valuats_containing_arrays
61
+ # Hermite curves use array args
62
+ s = parse 'Hermite(0,[-64,98.33,98.33]@1,[50,97.29,97.29]@4)'
63
+ ref = [[:funcall, "Hermite",
64
+ [:atom_i, 0],
65
+ [:arr, [:atom_f, -64.0], [:atom_f, 98.33], [:atom_f, 98.33]], [:atom_at_i, 1],
66
+ [:arr, [:atom_i, 50], [:atom_f, 97.29], [:atom_f, 97.29]], [:atom_at_i, 4]
67
+ ]]
68
+ assert_equal ref, s
69
+ end
70
+
71
+ def test_parse_from_start_injects_comment
72
+ p = File.open(P){|f| f.read(1600) }
73
+ tree = parse(p)
74
+ assert_equal :comment, tree[0][0]
75
+ assert_equal :comment, tree[1][0]
76
+ assert_equal :funcall, tree[2][0]
77
+ end
78
+
79
+ def test_parse_varassign
80
+ s = parse 'Foo = Blur(Foo, 1, 2, 3);'
81
+ assert_equal [[:var, "Foo"], [:eq], [:funcall, "Blur", [:atom, "Foo"], [:atom_i, 1],
82
+ [:atom_i, 2], [:atom_i, 3]]], s
83
+ end
84
+
85
+ def test_parse_whole_file_does_not_raise
86
+ assert_nothing_raised do
87
+ parse(File.open(P), L)
88
+ end
89
+ end
90
+
91
+ def parse(s, klass = L)
92
+ s = StringIO.new(s) unless s.respond_to?(:read)
93
+ klass.new(s).stack
94
+ end
95
+ end
@@ -0,0 +1,75 @@
1
+ require File.dirname(__FILE__) + '/../helper'
2
+
3
+ class ShakeScriptImportTest < Test::Unit::TestCase
4
+ DELTA = 0.001
5
+
6
+ def test_parsing_fifty_tracker_nodes_with_one_track_each
7
+ fixture = File.open(File.dirname(__FILE__) + '/samples/shake_tracker_nodes.shk')
8
+
9
+ trackers = Tracksperanto::Import::ShakeScript.new.parse(fixture)
10
+ assert_equal 50, trackers.length
11
+
12
+ t = trackers[0]
13
+ assert_equal "Tracker1_track1", t.name
14
+
15
+ first_kf = t.keyframes[0]
16
+ assert_equal 0, first_kf.frame
17
+ assert_in_delta 886.212, first_kf.abs_y, DELTA
18
+ assert_in_delta 715.839, first_kf.abs_x, DELTA
19
+ assert_in_delta 0.0, first_kf.residual, DELTA
20
+
21
+ second_kf = t.keyframes[1]
22
+ assert_in_delta 0.00129, second_kf.residual, DELTA
23
+ end
24
+
25
+ def test_parsing_two_tracks_in_one_tracker_node
26
+ fixture = File.open(File.dirname(__FILE__) + '/samples/two_tracks_in_one_tracker.shk')
27
+
28
+ trackers = Tracksperanto::Import::ShakeScript.new.parse(fixture)
29
+ assert_equal 2, trackers.length
30
+
31
+ t = trackers[0]
32
+ assert_equal "Tracker1_track1", t.name
33
+
34
+ first_kf = t.keyframes[0]
35
+ assert_equal 0, first_kf.frame
36
+ assert_in_delta 716.08, first_kf.abs_x, DELTA
37
+ assert_in_delta 885.123, first_kf.abs_y, DELTA
38
+ assert_in_delta 0.0, first_kf.residual, DELTA
39
+
40
+ second_kf = t.keyframes[1]
41
+ assert_in_delta 0.00129, second_kf.residual, DELTA
42
+
43
+ t2 = trackers[1]
44
+ assert_equal "Tracker1_track2", t2.name
45
+
46
+ end
47
+
48
+ def test_parsing_three_tracks_in_one_stabilizer_node
49
+ fixture = File.open(File.dirname(__FILE__) + '/samples/three_tracks_in_one_stabilizer.shk')
50
+
51
+ trackers = Tracksperanto::Import::ShakeScript.new.parse(fixture)
52
+ ft = trackers[0]
53
+ assert_equal "Stabilize1_track1", ft.name
54
+ assert_equal 3, trackers.length
55
+ end
56
+
57
+ def test_parsing_four_tracks_in_one_stabilizer_node
58
+ fixture = File.open(File.dirname(__FILE__) + '/samples/four_tracks_in_one_stabilizer.shk')
59
+
60
+ trackers = Tracksperanto::Import::ShakeScript.new.parse(fixture)
61
+ ft = trackers[0]
62
+ assert_equal "Stabilize2_track1", ft.name
63
+ assert_equal 4, trackers.length
64
+ end
65
+
66
+ def test_parsing_four_tracks_in_one_matchmove_node
67
+ fixture = File.open(File.dirname(__FILE__) + '/samples/four_tracks_in_one_matchmove.shk')
68
+
69
+ trackers = Tracksperanto::Import::ShakeScript.new.parse(fixture)
70
+ assert_equal 4, trackers.length
71
+
72
+ ft = trackers[0]
73
+ assert_equal "MatchMove1_track1", ft.name
74
+ end
75
+ end
@@ -1,9 +1,16 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.dirname(__FILE__) + '/../helper'
2
2
 
3
3
  class ShakeTextImportTest < Test::Unit::TestCase
4
4
  DELTA = 0.000001
5
+
6
+ def test_introspects_properly
7
+ i = Tracksperanto::Import::ShakeText
8
+ assert_equal "Shake .txt tracker file", i.human_name
9
+ assert !i.autodetects_size?
10
+ end
11
+
5
12
  def test_parsing
6
- fixture = File.read(File.dirname(__FILE__) + '/samples/one_shake_tracker.txt')
13
+ fixture = File.open(File.dirname(__FILE__) + '/samples/one_shake_tracker.txt')
7
14
  trackers = Tracksperanto::Import::ShakeText.new.parse(fixture)
8
15
 
9
16
  assert_kind_of Enumerable, trackers
@@ -23,7 +30,7 @@ class ShakeTextImportTest < Test::Unit::TestCase
23
30
  end
24
31
 
25
32
  def test_parsing_two_trackers
26
- fixture = File.read(File.dirname(__FILE__) + '/samples/two_shake_trackers.txt')
33
+ fixture = File.open(File.dirname(__FILE__) + '/samples/two_shake_trackers.txt')
27
34
  trackers = Tracksperanto::Import::ShakeText.new.parse(fixture)
28
35
 
29
36
  assert_kind_of Enumerable, trackers
@@ -1,10 +1,15 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.dirname(__FILE__) + '/../helper'
2
2
 
3
3
  class SyntheyesImportTest < Test::Unit::TestCase
4
- DELTA = 0.9 # our SynthEyes sample is smoewhat inaccurate :-P
4
+ DELTA = 0.9 # our SynthEyes sample is somewhat inaccurate :-P
5
+ def test_introspects_properly
6
+ i = Tracksperanto::Import::Syntheyes
7
+ assert_equal "Syntheyes tracker export (UV) file", i.human_name
8
+ assert !i.autodetects_size?
9
+ end
5
10
 
6
11
  def test_parsing_from_importable
7
- fixture = File.read(File.dirname(__FILE__) + '/samples/shake_tracker_nodes_to_syntheyes.txt')
12
+ fixture = File.open(File.dirname(__FILE__) + '/samples/shake_tracker_nodes_to_syntheyes.txt')
8
13
 
9
14
  parser = Tracksperanto::Import::Syntheyes.new
10
15
  parser.width = 2560
@@ -0,0 +1,32 @@
1
+ require File.dirname(__FILE__) + '/../helper'
2
+
3
+ class GoldenMiddlewareTest < Test::Unit::TestCase
4
+ def test_default_golden_set_to_false
5
+ receiver = flexmock
6
+ m = Tracksperanto::Middleware::Golden.new(receiver)
7
+ assert_equal false, m.enabled
8
+ end
9
+
10
+ def test_golden_supports_hash_init
11
+ receiver = flexmock
12
+ m = Tracksperanto::Middleware::Golden.new(receiver, :enabled => true)
13
+ assert_equal true, m.enabled
14
+ end
15
+
16
+ def test_golden_bypasses_methods
17
+ receiver = flexmock
18
+
19
+ receiver.should_receive(:start_export).once.with(120,120)
20
+ receiver.should_receive(:start_tracker_segment).once.with("Tracker")
21
+ receiver.should_receive(:export_point).once.with(0, 100, 100, 0.0)
22
+ receiver.should_receive(:end_tracker_segment).once
23
+ receiver.should_receive(:end_export).once
24
+
25
+ m = Tracksperanto::Middleware::Golden.new(receiver, :enabled => true)
26
+ m.start_export(120, 120)
27
+ m.start_tracker_segment("Tracker")
28
+ m.export_point(0, 100, 100, 0.56)
29
+ m.end_tracker_segment
30
+ m.end_export
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../helper'
2
+
3
+ class ReformatMiddlewareTest < Test::Unit::TestCase
4
+ def test_inherits_and_thus_complies
5
+ assert Tracksperanto::Middleware::Reformat.ancestors.include?(Tracksperanto::Middleware::Scaler)
6
+ end
7
+
8
+ def test_default_params_zeroed
9
+ receiver = flexmock
10
+ m = Tracksperanto::Middleware::Reformat.new(receiver)
11
+ assert_equal 0, m.width
12
+ assert_equal 0, m.height
13
+ end
14
+
15
+ def test_reformat_supports_hash_init
16
+ receiver = flexmock
17
+ m = Tracksperanto::Middleware::Reformat.new(receiver, :width => 1920, :height => 1080)
18
+ assert_equal 1920, m.width
19
+ assert_equal 1080, m.height
20
+ end
21
+
22
+ def test_reformat_bypasses_methods_and_sets_aspect
23
+ upscale_h = 2.66666666666667
24
+ upscale_v = 1.875
25
+
26
+ receiver = flexmock
27
+ receiver.should_receive(:start_export).once.with(1920,1080)
28
+
29
+ m = Tracksperanto::Middleware::Reformat.new(receiver, :width => 1920, :height => 1080)
30
+
31
+ m.start_export(720, 576)
32
+ assert_in_delta upscale_h, m.send(:x_factor), 0.00001, "The middleware should have configured the x factor on export start"
33
+ assert_in_delta upscale_v, m.send(:y_factor), 0.00001, "The middleware should have configured the y factor on export start"
34
+ end
35
+ end