Author: pmdumuid
Date: 2007-12-21 10:21:44 +0100 (Fri, 21 Dec 2007)
New Revision: 1043
Modified:
trunk/hvirtual/plugins/motion/motion.C
trunk/hvirtual/plugins/motion/motion.h
trunk/hvirtual/plugins/motion/motionwindow.C
trunk/hvirtual/plugins/motion/motionwindow.h
Log:
PLUGIN:Motion - Ability to add offsets from tracked frame
To stabilize video, the motion plugin uses a "tracking frame" to which
to track to and a region within that frame to track (generally an
object in the background) in the current frame. When the region is
obscured, (often by something in the foreground, or by leaving the
screen), then the motion compensation would fail, and the video jump's
all over the place.
This patch helps work around the problem by allowing one to set a
second region to track and then add offset the (previously calculated and
saved to the respective file in /tmp/???/)
Here's how I use it:
Timeline: k--------k-----------------------
^ ^^
A BC
A - object1 is visible in the background up until C
B - (the frame before C) has both object1 and object2 visible
C - has only object2 visible
1. Make a keyframe and set to track object1
2. Make a keyframe at C and track frame at B, set to track object2
3. Set keyframe at C to add offsets that were calcuated at B.
Done! And it works REALLY well!!! (I am really happy with this! :P)
Modified: trunk/hvirtual/plugins/motion/motion.C
===================================================================
--- trunk/hvirtual/plugins/motion/motion.C 2007-12-02 04:08:23 UTC (rev 1042)
+++ trunk/hvirtual/plugins/motion/motion.C 2007-12-21 09:21:44 UTC (rev 1043)
@@ -65,6 +65,7 @@
mode1 = STABILIZE;
global = 1;
rotate = 1;
+ addtrackedframeoffset = 0;
mode2 = NO_CALCULATE;
draw_vectors = 1;
mode3 = MotionConfig::TRACK_SINGLE;
@@ -94,6 +95,7 @@
mode1 == that.mode1 &&
global == that.global &&
rotate == that.rotate &&
+ addtrackedframeoffset == that.addtrackedframeoffset &&
draw_vectors == that.draw_vectors &&
block_count == that.block_count &&
global_block_w == that.global_block_w &&
@@ -121,6 +123,7 @@
mode1 = that.mode1;
global = that.global;
rotate = that.rotate;
+ addtrackedframeoffset = that.addtrackedframeoffset;
mode2 = that.mode2;
draw_vectors = that.draw_vectors;
block_count = that.block_count;
@@ -157,6 +160,7 @@
mode1 = prev.mode1;
global = prev.global;
rotate = prev.rotate;
+ addtrackedframeoffset = prev.addtrackedframeoffset;
mode2 = prev.mode2;
draw_vectors = prev.draw_vectors;
block_count = prev.block_count;
@@ -406,6 +410,7 @@
output.tag.set_property("MODE1", config.mode1);
output.tag.set_property("GLOBAL", config.global);
output.tag.set_property("ROTATE", config.rotate);
+ output.tag.set_property("ADDTRACKEDFRAMEOFFSET", config.addtrackedframeoffset);
output.tag.set_property("MODE2", config.mode2);
output.tag.set_property("DRAW_VECTORS", config.draw_vectors);
output.tag.set_property("MODE3", config.mode3);
@@ -452,6 +457,7 @@
config.mode1 = input.tag.get_property("MODE1", config.mode1);
config.global = input.tag.get_property("GLOBAL", config.global);
config.rotate = input.tag.get_property("ROTATE", config.rotate);
+ config.addtrackedframeoffset = input.tag.get_property("ADDTRACKEDFRAMEOFFSET", config.addtrackedframeoffset);
config.mode2 = input.tag.get_property("MODE2", config.mode2);
config.draw_vectors = input.tag.get_property("DRAW_VECTORS", config.draw_vectors);
config.mode3 = input.tag.get_property("MODE3", config.mode3);
@@ -2271,6 +2277,25 @@
dx_result *= -1;
dy_result *= -1;
+
+ // Add offsets from the "tracked single frame"
+ if (plugin->config.addtrackedframeoffset) {
+ int tf_dx_result, tf_dy_result;
+ char string[BCTEXTLEN];
+ sprintf(string, "%s%06d", MOTION_FILE, plugin->config.track_frame);
+ FILE *input = fopen(string, "r");
+ if(input)
+ {
+ fscanf(input,
+ "%d %d",
+ &tf_dx_result,
+ &tf_dy_result);
+ dx_result += tf_dx_result;
+ dy_result += tf_dy_result;
+ fclose(input);
+ }
+ }
+
}
Modified: trunk/hvirtual/plugins/motion/motion.h
===================================================================
--- trunk/hvirtual/plugins/motion/motion.h 2007-12-02 04:08:23 UTC (rev 1042)
+++ trunk/hvirtual/plugins/motion/motion.h 2007-12-21 09:21:44 UTC (rev 1043)
@@ -84,6 +84,7 @@
int vertical_only;
int global;
int rotate;
+ int addtrackedframeoffset;
// Track or stabilize, single pixel, scan only, or nothing
int mode1;
// Recalculate, no calculate, save, or load coordinates from disk
Modified: trunk/hvirtual/plugins/motion/motionwindow.C
===================================================================
--- trunk/hvirtual/plugins/motion/motionwindow.C 2007-12-02 04:08:23 UTC (rev 1042)
+++ trunk/hvirtual/plugins/motion/motionwindow.C 2007-12-21 09:21:44 UTC (rev 1043)
@@ -17,9 +17,9 @@
: BC_Window(plugin->gui_string,
x,
y,
- 600,
+ 610,
650,
- 600,
+ 610,
650,
0,
1)
@@ -172,7 +172,13 @@
this,
x + track_single->get_w() + title->get_w() + 20,
y));
+ xpmd = x + track_single->get_w() + title->get_w() + 20 + track_frame_number->get_w();
+ add_subwindow(addtrackedframeoffset = new AddTrackedFrameOffset(plugin,
+ this,
+ xpmd,
+ y));
+
y += 20;
add_subwindow(track_previous = new TrackPreviousFrame(plugin,
this,
@@ -235,6 +241,7 @@
vectors->update(plugin->config.draw_vectors);
global->update(plugin->config.global);
rotate->update(plugin->config.rotate);
+ addtrackedframeoffset->update(plugin->config.addtrackedframeoffset);
}
@@ -457,8 +464,27 @@
+AddTrackedFrameOffset::AddTrackedFrameOffset(MotionMain *plugin,
+ MotionWindow *gui,
+ int x,
+ int y)
+ : BC_CheckBox(x,
+ y,
+ plugin->config.addtrackedframeoffset,
+ _("Add (loaded) offset from tracked frame"))
+{
+ this->plugin = plugin;
+ this->gui = gui;
+}
+int AddTrackedFrameOffset::handle_event()
+{
+ plugin->config.addtrackedframeoffset = get_value();
+ plugin->send_configure_change();
+ return 1;
+}
+
MotionGlobal::MotionGlobal(MotionMain *plugin,
MotionWindow *gui,
int x,
Modified: trunk/hvirtual/plugins/motion/motionwindow.h
===================================================================
--- trunk/hvirtual/plugins/motion/motionwindow.h 2007-12-02 04:08:23 UTC (rev 1042)
+++ trunk/hvirtual/plugins/motion/motionwindow.h 2007-12-21 09:21:44 UTC (rev 1043)
@@ -242,6 +242,17 @@
MotionWindow *gui;
};
+class AddTrackedFrameOffset : public BC_CheckBox
+{
+public:
+ AddTrackedFrameOffset(MotionMain *plugin,
+ MotionWindow *gui,
+ int x,
+ int y);
+ int handle_event();
+ MotionWindow *gui;
+ MotionMain *plugin;
+};
class MotionGlobal : public BC_CheckBox
{
@@ -299,6 +310,7 @@
MotionDrawVectors *vectors;
MotionGlobal *global;
MotionRotate *rotate;
+ AddTrackedFrameOffset *addtrackedframeoffset;
TrackSingleFrame *track_single;
TrackFrameNumber *track_frame_number;
TrackPreviousFrame *track_previous;
_______________________________________________
Cinelerra-commits mailing list
Cinelerra-commits@???
https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra-commits