tracksperanto 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 2.1.0 / 2011-02-08
2
+ * Adds PFMatchit import support. Also all PFTrack imported cameras will have a camera name injected into the tracker
3
+ * Adds a PFMatchit exporter (PFMatchit only wants cameras with numbers in the name)
4
+
1
5
  === 2.0.2 / 2011-02-02
2
6
  * Compatible with Ruby 1.9.2
3
7
  * Scaler middleware now supports negative scaling factors
data/Manifest.txt CHANGED
@@ -13,6 +13,7 @@ lib/export/match_mover.rb
13
13
  lib/export/maya_live.rb
14
14
  lib/export/mux.rb
15
15
  lib/export/nuke_script.rb
16
+ lib/export/pfmatchit.rb
16
17
  lib/export/pftrack.rb
17
18
  lib/export/pftrack_5.rb
18
19
  lib/export/shake_text.rb
@@ -64,6 +65,7 @@ test/export/README_EXPORT_TESTS.txt
64
65
  test/export/samples/ref_Mayalive.txt
65
66
  test/export/samples/ref_Mayalive_CustomAspect.txt
66
67
  test/export/samples/ref_NukeScript.nk
68
+ test/export/samples/ref_PFMatchit.2dt
67
69
  test/export/samples/ref_PFTrack.2dt
68
70
  test/export/samples/ref_PFTrack5.2dt
69
71
  test/export/samples/ref_ShakeText.txt
@@ -81,6 +83,7 @@ test/export/test_match_mover_export.rb
81
83
  test/export/test_maya_live_export.rb
82
84
  test/export/test_mux.rb
83
85
  test/export/test_nuke_export.rb
86
+ test/export/test_pfmatchit_export.rb
84
87
  test/export/test_pftrack5_export.rb
85
88
  test/export/test_pftrack_export.rb
86
89
  test/export/test_shake_export.rb
@@ -101,6 +104,7 @@ test/import/samples/nuke/one_tracker_with_break.nk
101
104
  test/import/samples/nuke/one_tracker_with_break_in_grp.nk
102
105
  test/import/samples/nuke/tracker_with_differing_gaps.nk
103
106
  test/import/samples/nuke/tracker_with_repeating_gaps.nk
107
+ test/import/samples/pfmatchit/pfmatchit_example.2dt
104
108
  test/import/samples/pftrack4/sourcefile_pftrack.2dt
105
109
  test/import/samples/pftrack5/apft.2dt
106
110
  test/import/samples/pftrack5/garage.2dt
@@ -0,0 +1,49 @@
1
+ # Export for PFMatchit
2
+ class Tracksperanto::Export::PFMatchit < Tracksperanto::Export::Base
3
+
4
+ # PFtrack wants cross-platform linebreaks
5
+ LINEBREAK = "\r\n"
6
+ KEYFRAME_TEMPLATE = "%s %.3f %.3f %.3f\r\n"
7
+
8
+ def self.desc_and_extension
9
+ "pfmatchit.2dt"
10
+ end
11
+
12
+ def self.human_name
13
+ "PFMatchit .2dt file (single camera)"
14
+ end
15
+
16
+ def start_tracker_segment(tracker_name)
17
+ # Setup for the next tracker
18
+ @frame_count = 0
19
+ @tracker_name = tracker_name
20
+ @tracker_io = Tracksperanto::BufferIO.new
21
+ end
22
+
23
+ # TODO: currently exports to one camera
24
+ def end_tracker_segment
25
+ 2.times { @io.write(LINEBREAK) }
26
+ @io.write(@tracker_name.inspect) # autoquotes
27
+ @io.write LINEBREAK
28
+ @io.write camera_name # For primary/secondary cam in stereo pair
29
+ @io.write LINEBREAK
30
+ @io.write @frame_count
31
+ @io.write LINEBREAK
32
+
33
+ @tracker_io.rewind
34
+ @io.write(@tracker_io.read) until @tracker_io.eof?
35
+ @tracker_io.close!
36
+ end
37
+
38
+ def export_point(frame, abs_float_x, abs_float_y, float_residual)
39
+ @frame_count += 1
40
+ line = KEYFRAME_TEMPLATE % [frame, abs_float_x, abs_float_y, float_residual / 8]
41
+ @tracker_io.write(line)
42
+ end
43
+
44
+ private
45
+
46
+ def camera_name
47
+ "1"
48
+ end
49
+ end
@@ -1,25 +1,17 @@
1
1
  # Export for PFTrack .2dt files for version 5
2
- class Tracksperanto::Export::PFTrack5 < Tracksperanto::Export::PFTrack4
2
+ class Tracksperanto::Export::PFTrack5 < Tracksperanto::Export::PFMatchit
3
3
 
4
4
  def self.desc_and_extension
5
5
  "pftrack_v5.2dt"
6
6
  end
7
7
 
8
8
  def self.human_name
9
- "PFTrack v5 .2dt file"
9
+ "PFTrack v5 .2dt file (single camera)"
10
10
  end
11
11
 
12
- def end_tracker_segment
13
- 2.times { @io.write(LINEBREAK) }
14
- @io.write(@tracker_name.inspect) # autoquotes
15
- @io.write(LINEBREAK)
16
- @io.write("Primary".inspect) # For primary/secondary cam in stereo pair
17
- @io.write(LINEBREAK)
18
- @io.write(@frame_count)
19
- @io.write(LINEBREAK)
20
-
21
- @tracker_io.rewind
22
- @io.write(@tracker_io.read) until @tracker_io.eof?
23
- @tracker_io.close!
12
+ private
13
+
14
+ def camera_name
15
+ "Primary".inspect
24
16
  end
25
17
  end
@@ -1,6 +1,6 @@
1
1
  class Tracksperanto::Import::PFTrack < Tracksperanto::Import::Base
2
2
  def self.human_name
3
- "PFTrack .2dt file"
3
+ "PFTrack/PFMatchit .2dt file"
4
4
  end
5
5
 
6
6
  def self.distinct_file_ext
@@ -8,6 +8,7 @@ class Tracksperanto::Import::PFTrack < Tracksperanto::Import::Base
8
8
  end
9
9
 
10
10
  CHARACTERS_OR_QUOTES = /[AZaz"]/
11
+ INTS = /^\d+$/
11
12
 
12
13
  def stream_parse(io)
13
14
  until io.eof?
@@ -15,7 +16,7 @@ class Tracksperanto::Import::PFTrack < Tracksperanto::Import::Base
15
16
  next if (!line || line =~ /^#/)
16
17
 
17
18
  if line =~ CHARACTERS_OR_QUOTES # Tracker with a name
18
- t = Tracksperanto::Tracker.new{|t| t.name = line.strip.gsub(/"/, '') }
19
+ t = Tracksperanto::Tracker.new{|t| t.name = unquote(line.strip) }
19
20
  report_progress("Reading tracker #{t.name}")
20
21
  parse_tracker(t, io)
21
22
  send_tracker(t)
@@ -27,15 +28,31 @@ class Tracksperanto::Import::PFTrack < Tracksperanto::Import::Base
27
28
  def parse_tracker(t, io)
28
29
  first_tracker_line = io.gets.chomp
29
30
 
30
- if first_tracker_line =~ CHARACTERS_OR_QUOTES # PFTrack version 5 format
31
- first_tracker_line = io.gets.chomp
31
+ # We will be reading one line too many possibly, so we need to know
32
+ # where to return to in case we do
33
+ first_data_offset = io.pos
34
+ second_tracker_line = io.gets.chomp
35
+
36
+ # Camera name in version 5 format, might be integer might be string
37
+ if first_tracker_line =~ CHARACTERS_OR_QUOTES || second_tracker_line =~ INTS
38
+ # Add cam name to the tracker
39
+ t.name += ("_%s" % unquote(first_tracker_line))
40
+ num_of_keyframes = second_tracker_line.to_i
41
+ else
42
+ num_of_keyframes = first_tracker_line.to_i
43
+ # Backtrack to where we were on this IO so that the first line read will be the tracker
44
+ report_progress("Backtracking to the beginning of data block")
45
+ io.seek(first_data_offset)
32
46
  end
33
47
 
34
- num_of_keyframes = first_tracker_line.to_i
35
48
  (1..num_of_keyframes).map do | keyframe_idx |
36
49
  report_progress("Reading keyframe #{keyframe_idx} of #{num_of_keyframes} in #{t.name}")
37
50
  f, x, y, residual = io.gets.chomp.split
38
51
  t.keyframe!(:frame => f, :abs_x => x, :abs_y => y, :residual => residual.to_f * 8)
39
52
  end
40
53
  end
54
+
55
+ def unquote(s)
56
+ s.gsub(/"/, '')
57
+ end
41
58
  end
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.0.2'
7
+ VERSION = '2.1.0'
8
8
 
9
9
  module Import; end
10
10
  module Export; end
@@ -0,0 +1,54 @@
1
+
2
+
3
+ "Parabolic_1_from_top_left"
4
+ 1
5
+ 19
6
+ 0 0.000 1080.000 0.000
7
+ 1 96.000 874.800 0.006
8
+ 2 192.000 691.200 0.012
9
+ 3 288.000 529.200 0.018
10
+ 4 384.000 388.800 0.024
11
+ 5 480.000 270.000 0.030
12
+ 6 576.000 172.800 0.036
13
+ 7 672.000 97.200 0.042
14
+ 8 768.000 43.200 0.048
15
+ 9 864.000 10.800 0.054
16
+ 12 1152.000 43.200 0.071
17
+ 13 1248.000 97.200 0.077
18
+ 14 1344.000 172.800 0.083
19
+ 15 1440.000 270.000 0.089
20
+ 16 1536.000 388.800 0.095
21
+ 17 1632.000 529.200 0.101
22
+ 18 1728.000 691.200 0.107
23
+ 19 1824.000 874.800 0.113
24
+ 20 1920.000 1080.000 0.119
25
+
26
+
27
+ "Parabolic_2_from_bottom_right"
28
+ 1
29
+ 19
30
+ 0 1920.000 0.000 0.000
31
+ 1 1824.000 205.200 0.006
32
+ 2 1728.000 388.800 0.012
33
+ 3 1632.000 550.800 0.018
34
+ 4 1536.000 691.200 0.024
35
+ 5 1440.000 810.000 0.030
36
+ 6 1344.000 907.200 0.036
37
+ 7 1248.000 982.800 0.042
38
+ 8 1152.000 1036.800 0.048
39
+ 9 1056.000 1069.200 0.054
40
+ 12 768.000 1036.800 0.071
41
+ 13 672.000 982.800 0.077
42
+ 14 576.000 907.200 0.083
43
+ 15 480.000 810.000 0.089
44
+ 16 384.000 691.200 0.095
45
+ 17 288.000 550.800 0.101
46
+ 18 192.000 388.800 0.107
47
+ 19 96.000 205.200 0.113
48
+ 20 0.000 0.000 0.119
49
+
50
+
51
+ "SingleFrame"
52
+ 1
53
+ 1
54
+ 0 970.000 550.000 0.000
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__)) + '/../helper'
2
+
3
+ class PFMatchitExportTest < Test::Unit::TestCase
4
+ include ParabolicTracks
5
+
6
+ def test_human_name
7
+ assert_equal "PFMatchit .2dt file (single camera)", Tracksperanto::Export::PFMatchit.human_name
8
+ end
9
+
10
+ def test_desc_and_ext
11
+ assert_equal "pfmatchit.2dt", Tracksperanto::Export::PFMatchit.desc_and_extension
12
+ end
13
+
14
+ P = File.dirname(__FILE__) + "/samples/ref_PFMatchit.2dt"
15
+
16
+ def test_export_output_written
17
+ ensure_same_output Tracksperanto::Export::PFMatchit, P
18
+ end
19
+ end
@@ -4,7 +4,7 @@ class PFTrack5ExportTest < Test::Unit::TestCase
4
4
  include ParabolicTracks
5
5
 
6
6
  def test_human_name
7
- assert_equal "PFTrack v5 .2dt file", Tracksperanto::Export::PFTrack5.human_name
7
+ assert_equal "PFTrack v5 .2dt file (single camera)", Tracksperanto::Export::PFTrack5.human_name
8
8
  end
9
9
 
10
10
  def test_desc_and_ext
@@ -0,0 +1,90 @@
1
+ # 2D feature tracks generated by PFTrack 5.0r11-100916
2
+ #
3
+ # format:
4
+ # "name"
5
+ # "camera"
6
+ # <number of frames>
7
+ # <frame number> <x pixel> <y pixel> <residual>
8
+ #
9
+
10
+ "Feature1"
11
+ 1
12
+ 37
13
+ 1 356.268 150.052 0.000
14
+ 2 355.768 148.141 0.000
15
+ 3 355.315 146.628 0.000
16
+ 4 355.084 145.346 0.004
17
+ 5 354.703 143.693 0.004
18
+ 6 354.334 141.926 0.004
19
+ 7 353.875 139.789 0.004
20
+ 8 353.293 137.673 0.004
21
+ 9 352.957 135.593 0.005
22
+ 10 352.601 133.629 0.006
23
+ 11 352.161 131.554 0.005
24
+ 12 351.746 129.328 0.006
25
+ 13 351.345 126.772 0.005
26
+ 14 350.899 124.121 0.005
27
+ 15 350.471 121.715 0.005
28
+ 16 350.200 119.275 0.005
29
+ 17 349.821 116.808 0.005
30
+ 18 349.593 114.196 0.006
31
+ 19 349.354 111.385 0.006
32
+ 20 349.240 108.501 0.007
33
+ 21 348.879 105.663 0.007
34
+ 22 348.597 102.901 0.007
35
+ 23 348.280 99.636 0.007
36
+ 24 348.182 95.489 0.007
37
+ 25 347.926 90.646 0.008
38
+ 26 347.855 85.444 0.007
39
+ 27 347.745 79.815 0.007
40
+ 28 347.543 73.971 0.008
41
+ 29 347.491 68.102 0.008
42
+ 30 347.103 62.183 0.009
43
+ 31 347.074 56.082 0.009
44
+ 32 346.845 49.360 0.009
45
+ 33 346.444 42.439 0.010
46
+ 34 346.642 36.103 0.010
47
+ 35 346.598 30.438 0.010
48
+ 36 346.110 24.721 0.011
49
+ 37 346.091 18.761 0.011
50
+
51
+ "Feature1"
52
+ 2
53
+ 37
54
+ 1 356.797 148.595 0.028
55
+ 2 356.272 146.782 0.028
56
+ 3 355.826 145.174 0.028
57
+ 4 355.501 143.803 0.027
58
+ 5 355.173 142.312 0.028
59
+ 6 354.749 140.375 0.027
60
+ 7 354.266 138.306 0.028
61
+ 8 353.697 136.171 0.029
62
+ 9 353.345 134.160 0.028
63
+ 10 352.957 132.128 0.027
64
+ 11 352.464 130.070 0.028
65
+ 12 352.039 127.815 0.026
66
+ 13 351.634 125.371 0.026
67
+ 14 351.183 122.809 0.027
68
+ 15 350.732 120.310 0.026
69
+ 16 350.442 117.903 0.027
70
+ 17 350.031 115.412 0.025
71
+ 18 349.744 112.833 0.026
72
+ 19 349.536 110.071 0.025
73
+ 20 349.397 107.185 0.026
74
+ 21 349.043 104.349 0.026
75
+ 22 348.683 101.514 0.025
76
+ 23 348.330 98.224 0.026
77
+ 24 348.192 94.154 0.026
78
+ 25 347.935 89.365 0.026
79
+ 26 347.823 84.114 0.025
80
+ 27 347.679 78.538 0.024
81
+ 28 347.441 72.707 0.025
82
+ 29 347.353 66.879 0.024
83
+ 30 346.953 61.081 0.025
84
+ 31 346.889 54.821 0.025
85
+ 32 346.624 48.160 0.024
86
+ 33 346.220 41.433 0.024
87
+ 34 346.302 35.097 0.023
88
+ 35 346.209 29.303 0.023
89
+ 36 345.718 23.658 0.022
90
+ 37 345.620 17.699 0.023
@@ -5,7 +5,7 @@ class PFTrackImportTest < Test::Unit::TestCase
5
5
 
6
6
  def test_introspects_properly
7
7
  i = Tracksperanto::Import::PFTrack
8
- assert_equal "PFTrack .2dt file", i.human_name
8
+ assert_equal "PFTrack/PFMatchit .2dt file", i.human_name
9
9
  assert !i.autodetects_size?
10
10
  end
11
11
 
@@ -16,7 +16,7 @@ class PFTrackImportTest < Test::Unit::TestCase
16
16
  trackers = parser.parse(fixture)
17
17
  assert_equal 4, trackers.length
18
18
  second_tracker = trackers[1]
19
- assert_equal "1015", second_tracker.name
19
+ assert_equal "1015_Primary", second_tracker.name
20
20
  end
21
21
 
22
22
  def test_parsing_from_importable_pftrack_4
@@ -53,8 +53,19 @@ class PFTrackImportTest < Test::Unit::TestCase
53
53
  parser = Tracksperanto::Import::PFTrack.new(:width => 1920, :height => 1080)
54
54
  trackers = parser.parse(fixture)
55
55
  assert_equal 250, trackers.length
56
- assert_equal "Tracker121", trackers[0].name
56
+ assert_equal "Tracker121_Primary", trackers[0].name
57
57
  assert_equal 189, trackers[0].length
58
58
  end
59
59
 
60
+ def test_pfmatchit_file
61
+ fixture = File.open(File.dirname(__FILE__) + '/samples/pfmatchit/pfmatchit_example.2dt')
62
+ parser = Tracksperanto::Import::PFTrack.new(:width => 1920, :height => 1080)
63
+ trackers = parser.parse(fixture)
64
+ assert_equal 2, trackers.length
65
+ assert_equal "Feature1_1", trackers[0].name
66
+ assert_equal 37, trackers[0].length
67
+ assert_equal "Feature1_2", trackers[1].name
68
+ assert_equal 37, trackers[1].length
69
+ end
70
+
60
71
  end
data/test/test_cli.rb CHANGED
@@ -49,7 +49,7 @@ class CliTest < Test::Unit::TestCase
49
49
  assert_equal 0, status, "Should exit with a normal status"
50
50
  fs = %w(. ..
51
51
  flm.stabilizer flm_3de_v3.txt flm_3de_v4.txt flm_boujou_text.txt flm_flame.stabilizer
52
- flm_matchmover.rz2 flm_mayalive.txt flm_nuke.nk flm_pftrack_v4.2dt
52
+ flm_matchmover.rz2 flm_mayalive.txt flm_nuke.nk flm_pfmatchit.2dt flm_pftrack_v4.2dt
53
53
  flm_pftrack_v5.2dt flm_shake_trackers.txt flm_syntheyes_2dt.txt
54
54
  )
55
55
 
@@ -85,7 +85,7 @@ class PipelineTest < Test::Unit::TestCase
85
85
  FileUtils.cp("./import/samples/shake_script/four_tracks_in_one_stabilizer.shk", "./input.shk")
86
86
  pipeline = Tracksperanto::Pipeline::Base.new
87
87
  assert_nothing_raised { pipeline.run("./input.shk", :importer => "Syntheyes", :width => 720, :height => 576) }
88
- assert_equal 12, Dir.glob("./input*").length, "Twelve files should be present for the input and outputs"
88
+ assert_equal 13, Dir.glob("./input*").length, "Twelve files should be present for the input and outputs"
89
89
  end
90
90
 
91
91
  def test_run_with_overridden_importer_and_size_for_file_that_would_be_recognized_differently
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 2
10
- version: 2.0.2
10
+ version: 2.1.0
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-02-02 00:00:00 +01:00
18
+ date: 2011-02-08 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -90,6 +90,7 @@ files:
90
90
  - lib/export/maya_live.rb
91
91
  - lib/export/mux.rb
92
92
  - lib/export/nuke_script.rb
93
+ - lib/export/pfmatchit.rb
93
94
  - lib/export/pftrack.rb
94
95
  - lib/export/pftrack_5.rb
95
96
  - lib/export/shake_text.rb
@@ -141,6 +142,7 @@ files:
141
142
  - test/export/samples/ref_Mayalive.txt
142
143
  - test/export/samples/ref_Mayalive_CustomAspect.txt
143
144
  - test/export/samples/ref_NukeScript.nk
145
+ - test/export/samples/ref_PFMatchit.2dt
144
146
  - test/export/samples/ref_PFTrack.2dt
145
147
  - test/export/samples/ref_PFTrack5.2dt
146
148
  - test/export/samples/ref_ShakeText.txt
@@ -158,6 +160,7 @@ files:
158
160
  - test/export/test_maya_live_export.rb
159
161
  - test/export/test_mux.rb
160
162
  - test/export/test_nuke_export.rb
163
+ - test/export/test_pfmatchit_export.rb
161
164
  - test/export/test_pftrack5_export.rb
162
165
  - test/export/test_pftrack_export.rb
163
166
  - test/export/test_shake_export.rb
@@ -178,6 +181,7 @@ files:
178
181
  - test/import/samples/nuke/one_tracker_with_break_in_grp.nk
179
182
  - test/import/samples/nuke/tracker_with_differing_gaps.nk
180
183
  - test/import/samples/nuke/tracker_with_repeating_gaps.nk
184
+ - test/import/samples/pfmatchit/pfmatchit_example.2dt
181
185
  - test/import/samples/pftrack4/sourcefile_pftrack.2dt
182
186
  - test/import/samples/pftrack5/apft.2dt
183
187
  - test/import/samples/pftrack5/garage.2dt
@@ -280,6 +284,7 @@ test_files:
280
284
  - test/export/test_maya_live_export.rb
281
285
  - test/export/test_mux.rb
282
286
  - test/export/test_nuke_export.rb
287
+ - test/export/test_pfmatchit_export.rb
283
288
  - test/export/test_pftrack5_export.rb
284
289
  - test/export/test_pftrack_export.rb
285
290
  - test/export/test_shake_export.rb