lib/import/flame_stabilizer.rb in tracksperanto-1.1.0 vs lib/import/flame_stabilizer.rb in tracksperanto-1.1.1
- old
+ new
@@ -147,15 +147,12 @@
def extract_channel_from(io, channel_name)
ChannelBlock.new(io, channel_name)
end
- def report_progress(msg)
- end
+ REF_CHANNEL = "ref" # or "track" - sometimes works sometimes don't
- REF_CHANNEL = "ref"
-
def scavenge_trackers_from_channels(channels)
trackers = []
channels.select{|e| e.name =~ /\/#{REF_CHANNEL}\/x/}.each do | track_x |
trackers << grab_tracker(channels, track_x)
end
@@ -164,10 +161,12 @@
end
def grab_tracker(channels, track_x)
t = T.new(:name => track_x.name.split('/').shift)
+ report_progress("Extracting tracker #{t.name}")
+
track_y = channels.find{|e| e.name == "#{t.name}/#{REF_CHANNEL}/y" }
shift_x = channels.find{|e| e.name == "#{t.name}/shift/x" }
shift_y = channels.find{|e| e.name == "#{t.name}/shift/y" }
shift_tuples = zip_channels(shift_x, shift_y)
@@ -177,20 +176,20 @@
find_base_x_and_y(track_tuples, shift_tuples)
rescue UseBase
[track_x.base_value, track_y.base_value]
end
+ total_kf = 1
t.keyframes = shift_tuples.map do | (at, x, y) |
# Flame keyframes are sort of minus-one based, so to start at frame 0
# we need to decrement one frame, always. Also, the shift value is inverted!
- K.new(:frame => (at - 1), :abs_x => (base_x - x.to_f), :abs_y => (base_y - y.to_f))
+ kf_x, kf_y = base_x - x.to_f, base_y - y.to_f
+
+ report_progress("Extracting keyframe #{total_kf += 1} of #{t.name}")
+ K.new(:frame => (at - 1), :abs_x => kf_x, :abs_y => kf_y)
end
return t
- end
-
- def cornerize(from_dimension, value_from_center)
- (from_dimension / 2.0) + (value_from_center * -1)
end
UseBase = RuntimeError
def find_base_x_and_y(track_tuples, shift_tuples)
\ No newline at end of file