From cinelerra-commits-admin@skolelinux.no  Fri Dec 21 04:22:37 2007
Return-Path: <cinelerra-commits-admin@skolelinux.no>
X-Original-To: cinelerra-commits@e.kevb.net
Delivered-To: cinelerra-commits@e.kevb.net
Received: from init.linpro.no (init.linpro.no [80.232.38.252])
	by e.kevb.net (Postfix) with ESMTP id D0CF3EC8012
	for <cinelerra-commits@e.kevb.net>; Fri, 21 Dec 2007 04:22:36 -0500 (EST)
Received: from localhost ([127.0.0.1] helo=init.linpro.no)
	by init.linpro.no with esmtp (Exim 4.50 #1 (Debian))
	id 1J5e5N-0006th-5Z; Fri, 21 Dec 2007 10:22:29 +0100
Received: from [193.69.32.11] (helo=virusvask01.itsjefen.no)
	by init.linpro.no with esmtp (Exim 4.50 #1 (Debian))
	id 1J5e50-0006rm-4U
	for <cinelerra-commits@skolelinux.no>; Fri, 21 Dec 2007 10:22:07 +0100
Received: from [193.69.32.11] by 80.232.38.252 (e-nough); Fri, 21 Dec 10:21:42 2007 +0100
Received: from localhost (localhost.localdomain [127.0.0.1])
	by virusvask01.itsjefen.no (Postfix) with ESMTP id B912E8AC105
	for <cinelerra-commits@skolelinux.no>; Fri, 21 Dec 2007 10:22:03 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at virusvask01.itsjefen.no
Received: from virusvask01.itsjefen.no ([127.0.0.1])
	by localhost (virusvask01.itsjefen.no [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id UiAkjxZP01Zx for <cinelerra-commits@skolelinux.no>;
	Fri, 21 Dec 2007 10:21:59 +0100 (CET)
Received: from mail-forward.uio.no (mail-forward.uio.no [129.240.10.42])
	by virusvask01.itsjefen.no (Postfix) with ESMTP id 6FD678AC104
	for <cinelerra-commits@skolelinux.no>; Fri, 21 Dec 2007 10:21:57 +0100 (CET)
Received: from mail-mx4.uio.no ([129.240.10.45])
	by pat.uio.no with esmtp (Exim 4.67)
	(envelope-from <pmdumuid@user.skolelinux.no>)
	id 1J5e4f-0004hV-8p
	for cinelerra-commits@skolelinux.no; Fri, 21 Dec 2007 10:21:45 +0100
Received: from user.skolelinux.no ([158.36.191.139])
	by mail-mx4.uio.no with esmtps (TLSv1:AES256-SHA:256)
	(Exim 4.67)
	(envelope-from <pmdumuid@user.skolelinux.no>)
	id 1J5e4e-00014j-Fr
	for cinelerra-commits@skolelinux.no; Fri, 21 Dec 2007 10:21:45 +0100
Received: from pmdumuid by user.skolelinux.no with local (Exim 4.63)
	(envelope-from <pmdumuid@user.skolelinux.no>)
	id 1J5e4e-0005aG-8Q
	for cinelerra-commits@skolelinux.no; Fri, 21 Dec 2007 10:21:44 +0100
To: cinelerra-commits@skolelinux.no
Content-Type: text/plain; charset=UTF-8
From: "Pierre Dumuid <pierre.dumuid@adelaide.edu.au>" <pmdumuid@user.skolelinux.no>
Message-Id: <E1J5e4e-0005aG-8Q@user.skolelinux.no>
X-UiO-ClamAV-Virus: No
X-UiO-Spam-info: not spam, SpamAssassin (score=0.0, required=5.0, autolearn=disabled, none)
X-UiO-Scanned: C64CC5D565393733C1D19785B22AFE69CAD700C5
X-UiO-SPAM-Test: remote_host: 158.36.191.139 spam_score: 0 maxlevel 200 minaction 2 bait 0 mail/h: 1 total 16551 max/h 1028 blacklist 0 greylist 0 ratelimit 0
Content-Transfer-Encoding: quoted-printable
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on spamtrap
X-Spam-Status: No, hits=0.0 required=5.0 tests=DSPAM=0	version=2.63
X-Spam-Level: 
X-DSPAM-Signature: !DSPAM:476b85b2166962119840995!
X-DSPAM-Probability: 0.0000
X-DSPAM-Confidence: 0.9997
X-Spam-Score: 0.0 (/)
Subject: [Cinelerra-commits] r1043 - trunk/hvirtual/plugins/motion
Sender: cinelerra-commits-admin@skolelinux.no
Errors-To: cinelerra-commits-admin@skolelinux.no
X-BeenThere: cinelerra-commits@skolelinux.no
X-Mailman-Version: 2.0.13
Precedence: bulk
List-Unsubscribe: <https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra-commits>,
	<mailto:cinelerra-commits-request@skolelinux.no?subject=unsubscribe>
List-Id: Commits to the Cinelerra CVS. <cinelerra-commits.skolelinux.no>
List-Post: <mailto:cinelerra-commits@skolelinux.no>
List-Help: <mailto:cinelerra-commits-request@skolelinux.no?subject=help>
List-Subscribe: <https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra-commits>,
	<mailto:cinelerra-commits-request@skolelinux.no?subject=subscribe>
List-Archive: <https://init.linpro.no/pipermail/skolelinux.no/cinelerra-commits/>
Date: Fri, 21 Dec 2007 10:21:44 +0100
X-Spam-Score: 0.0 (/)

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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/hvirtual/plugins/motion/motion.C	2007-12-02 04:08:23 UTC (rev 1=
042)
+++ trunk/hvirtual/plugins/motion/motion.C	2007-12-21 09:21:44 UTC (rev 1=
043)
@@ -65,6 +65,7 @@
 	mode1 =3D STABILIZE;
 	global =3D 1;
 	rotate =3D 1;
+	addtrackedframeoffset =3D 0;
 	mode2 =3D NO_CALCULATE;
 	draw_vectors =3D 1;
 	mode3 =3D MotionConfig::TRACK_SINGLE;
@@ -94,6 +95,7 @@
 		mode1 =3D=3D that.mode1 &&
 		global =3D=3D that.global &&
 		rotate =3D=3D that.rotate &&
+		addtrackedframeoffset =3D=3D that.addtrackedframeoffset &&
 		draw_vectors =3D=3D that.draw_vectors &&
 		block_count =3D=3D that.block_count &&
 		global_block_w =3D=3D that.global_block_w &&
@@ -121,6 +123,7 @@
 	mode1 =3D that.mode1;
 	global =3D that.global;
 	rotate =3D that.rotate;
+	addtrackedframeoffset =3D that.addtrackedframeoffset;
 	mode2 =3D that.mode2;
 	draw_vectors =3D that.draw_vectors;
 	block_count =3D that.block_count;
@@ -157,6 +160,7 @@
 	mode1 =3D prev.mode1;
 	global =3D prev.global;
 	rotate =3D prev.rotate;
+	addtrackedframeoffset =3D prev.addtrackedframeoffset;
 	mode2 =3D prev.mode2;
 	draw_vectors =3D prev.draw_vectors;
 	block_count =3D 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.addtrackedframe=
offset);
 	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 =3D input.tag.get_property("MODE1", config.mode1);
 				config.global =3D input.tag.get_property("GLOBAL", config.global);
 				config.rotate =3D input.tag.get_property("ROTATE", config.rotate);
+				config.addtrackedframeoffset =3D input.tag.get_property("ADDTRACKEDF=
RAMEOFFSET", config.addtrackedframeoffset);
 				config.mode2 =3D input.tag.get_property("MODE2", config.mode2);
 				config.draw_vectors =3D input.tag.get_property("DRAW_VECTORS", confi=
g.draw_vectors);
 				config.mode3 =3D input.tag.get_property("MODE3", config.mode3);
@@ -2271,6 +2277,25 @@
=20
 		dx_result *=3D -1;
 		dy_result *=3D -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 =3D fopen(string, "r");
+		  if(input)
+		    {
+		      fscanf(input,=20
+			     "%d %d",=20
+			     &tf_dx_result,
+			     &tf_dy_result);
+		      dx_result +=3D tf_dx_result;
+		      dy_result +=3D tf_dy_result;
+		      fclose(input);
+		    }
+		}
+
 	}
=20
=20

Modified: trunk/hvirtual/plugins/motion/motion.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/hvirtual/plugins/motion/motion.h	2007-12-02 04:08:23 UTC (rev 1=
042)
+++ trunk/hvirtual/plugins/motion/motion.h	2007-12-21 09:21:44 UTC (rev 1=
043)
@@ -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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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,=20
  	x,
 	y,
-	600,=20
+	610,=20
 	650,=20
-	600,
+	610,
 	650,
 	0,=20
 	1)
@@ -172,7 +172,13 @@
 		this,
 		x + track_single->get_w() + title->get_w() + 20,=20
 		y));
+	xpmd =3D x + track_single->get_w() + title->get_w() + 20 + track_frame_=
number->get_w();
+	add_subwindow(addtrackedframeoffset =3D new AddTrackedFrameOffset(plugi=
n,
+		this,
+		xpmd,
+		y));
=20
+
 	y +=3D 20;
 	add_subwindow(track_previous =3D new TrackPreviousFrame(plugin,=20
 		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);
 }
=20
=20
@@ -457,8 +464,27 @@
=20
=20
=20
+AddTrackedFrameOffset::AddTrackedFrameOffset(MotionMain *plugin,=20
+	MotionWindow *gui,
+	int x,=20
+	int y)
+ : BC_CheckBox(x,=20
+ 	y,=20
+	plugin->config.addtrackedframeoffset,
+	_("Add (loaded) offset from tracked frame"))
+{
+	this->plugin =3D plugin;
+	this->gui =3D gui;
+}
=20
+int AddTrackedFrameOffset::handle_event()
+{
+	plugin->config.addtrackedframeoffset =3D get_value();
+	plugin->send_configure_change();
+	return 1;
+}
=20
+
 MotionGlobal::MotionGlobal(MotionMain *plugin,=20
 	MotionWindow *gui,
 	int x,=20

Modified: trunk/hvirtual/plugins/motion/motionwindow.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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;
 };
=20
+class AddTrackedFrameOffset : public BC_CheckBox
+{
+public:
+	AddTrackedFrameOffset(MotionMain *plugin,=20
+		MotionWindow *gui,
+		int x,=20
+		int y);
+	int handle_event();
+	MotionWindow *gui;
+	MotionMain *plugin;
+};
=20
 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@skolelinux.no
https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra-commits
