Revision: 38828
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38828
Author: nazgul
Date: 2011-07-29 20:55:23 +0000 (Fri, 29 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================
Changed behavior of 2D stabilization:
- Fixed epic spelling error.
- Neither 3d viewport nor MovieClip compositor input node
are using stable footage now.
- Now one thread lock can be avoided -- stable shot
isn't acquiring from several threads.
- Added compositor noe Distort->Stabilize 2D which is
supposed to stabilize "incoming" image using movie clip
block as reference.
Probably it could be useful to define MAT4 socket type and
use it in MovieClip node as output for stabilization and
as input socket for Stabilization node so relation could be
easily visible on "graph".
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree.c
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree_types.h
branches/soc-2011-tomato/source/blender/nodes/CMP_node.h
branches/soc-2011-tomato/source/blender/nodes/CMakeLists.txt
branches/soc-2011-tomato/source/blender/nodes/intern/CMP_nodes/CMP_movieclip.c
Added Paths:
-----------
branches/soc-2011-tomato/source/blender/nodes/intern/CMP_nodes/CMP_stabilize2d.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
2011-07-29 20:46:30 UTC (rev 38827)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
2011-07-29 20:55:23 UTC (rev 38828)
@@ -388,6 +388,7 @@
#define CMP_NODE_COLORBALANCE 260
#define CMP_NODE_HUECORRECT 261
#define CMP_NODE_MOVIECLIP 262
+#define CMP_NODE_STABILIZE2D 263
#define CMP_NODE_GLARE 301
#define CMP_NODE_TONEMAP 302
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
2011-07-29 20:46:30 UTC (rev 38827)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
2011-07-29 20:55:23 UTC (rev 38828)
@@ -87,7 +87,8 @@
struct MovieTrackingTrack *BKE_tracking_indexed_bundle(struct MovieTracking
*tracking, int bundlenr);
-struct ImBuf *BKE_tracking_stabelize_shot(struct MovieTracking *tracking, int
framenr, struct ImBuf *ibuf, float mat[4][4]);
+void BKE_tracking_stabilization_matrix(struct MovieTracking *tracking, int
framenr, int width, int height, float mat[4][4]);
+struct ImBuf *BKE_tracking_stabilize_shot(struct MovieTracking *tracking, int
framenr, struct ImBuf *ibuf, float mat[4][4]);
#define TRACK_SELECTED(track)
(((track->flag&TRACK_HIDDEN)==0) && ((track)->flag&SELECT ||
(track)->pat_flag&SELECT || (track)->search_flag&SELECT))
#define TRACK_AREA_SELECTED(track, area)
(((track->flag&TRACK_HIDDEN)==0) &&
((area)==TRACK_AREA_POINT?(track)->flag&SELECT :
((area)==TRACK_AREA_PAT?(track)->pat_flag&SELECT:(track)->search_flag&SELECT)))
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
2011-07-29 20:46:30 UTC (rev 38827)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
2011-07-29 20:55:23 UTC (rev 38828)
@@ -331,16 +331,12 @@
if(clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) {
MovieTrackingStabilization *stab= &clip->tracking.stabilization;
- BLI_lock_thread(LOCK_MOVIECLIP);
-
if(user->framenr!=stab->framenr)
stab->ibufok= 0;
- stableibuf= BKE_tracking_stabelize_shot(&clip->tracking,
framenr, ibuf, mat);
+ stableibuf= BKE_tracking_stabilize_shot(&clip->tracking,
framenr, ibuf, mat);
stab->framenr= user->framenr;
-
- BLI_unlock_thread(LOCK_MOVIECLIP);
} else {
if(mat)
unit_m4(mat);
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c
2011-07-29 20:46:30 UTC (rev 38827)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c
2011-07-29 20:55:23 UTC (rev 38828)
@@ -3305,7 +3305,7 @@
NodeTagChanged(ntree, node);
}
}
- else if(node->type==CMP_NODE_MOVIECLIP) {
+ else if(ELEM(node->type, CMP_NODE_MOVIECLIP,
CMP_NODE_STABILIZE2D)) {
NodeTagChanged(ntree, node);
tagged= 1;
}
@@ -3520,6 +3520,7 @@
register_node_type_cmp_glare(ntypelist);
register_node_type_cmp_tonemap(ntypelist);
register_node_type_cmp_lensdist(ntypelist);
+ register_node_type_cmp_stabilize2d(ntypelist);
}
static void registerShaderNodes(ListBase *ntypelist)
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
2011-07-29 20:46:30 UTC (rev 38827)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
2011-07-29 20:55:23 UTC (rev 38828)
@@ -1310,17 +1310,15 @@
mat[0][0]= stab->scale;
mat[1][1]= stab->scale;
+ mat[2][2]= stab->scale;
mat[3][0]= (firstmedian[0]-curmedian[0])*width*stab->scale;
mat[3][1]= (firstmedian[1]-curmedian[1])*height*stab->scale;
mat[3][0]-= (firstmedian[0]*stab->scale-firstmedian[0])*width;
mat[3][1]-= (firstmedian[1]*stab->scale-firstmedian[1])*height;
- /*mat[3][0]-= (width*stab->scale-width)/2.0f;
- mat[3][1]-= (height*stab->scale-height)/2.0f;*/
-
}
-static int stabelize_need_recalc(MovieTracking *tracking, float width, float
height,
+static int stabilize_need_recalc(MovieTracking *tracking, float width, float
height,
float firstmedian[2], float curmedian[2], float
mat[4][4])
{
float stabmat[4][4];
@@ -1337,7 +1335,7 @@
return memcmp(mat, stabmat, sizeof(float)*16);
}
-static ImBuf* stabelize_acquire_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int
fill)
+static ImBuf* stabilize_acquire_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int
fill)
{
int flags;
@@ -1365,12 +1363,52 @@
return cacheibuf;
}
-ImBuf *BKE_tracking_stabelize_shot(MovieTracking *tracking, int framenr, ImBuf
*ibuf, float mat[4][4])
+void BKE_tracking_stabilization_matrix(MovieTracking *tracking, int framenr,
int width, int height, float mat[4][4])
{
float firstmedian[2], curmedian[2], stabmat[4][4];
MovieTrackingStabilization *stab= &tracking->stabilization;
+ copy_m4_m4(stabmat, mat);
+
+ if((stab->flag&TRACKING_2D_STABILIZATION)==0) {
+ unit_m4(mat);
+
+ return;
+ }
+
+ if(stabilization_median_point(tracking, 1, firstmedian)) {
+ stabilization_median_point(tracking, framenr, curmedian);
+
+ if((stab->flag&TRACKING_AUTOSCALE)==0)
+ stab->scale= 1.f;
+
+ if(!stab->ok && stab->ibufok && stab->ibuf)
+ stab->ibufok= stabilize_need_recalc(tracking, width,
height, firstmedian, curmedian, mat) == 0;
+
+ if(!stab->ibuf || !stab->ibufok) {
+ if(stab->flag&TRACKING_AUTOSCALE)
+ stabilization_auto_scale_factor(tracking);
+
+ calculate_stabmat(stab, width, height, firstmedian,
curmedian, stabmat);
+
+ stab->ok= 1;
+ } else {
+ calculate_stabmat(stab, width, height, firstmedian,
curmedian, stabmat);
+ }
+ } else {
+ unit_m4(stabmat);
+ }
+
if(mat)
+ copy_m4_m4(mat, stabmat);
+}
+
+ImBuf *BKE_tracking_stabilize_shot(MovieTracking *tracking, int framenr, ImBuf
*ibuf, float mat[4][4])
+{
+ float firstmedian[2], curmedian[2], stabmat[4][4];
+ MovieTrackingStabilization *stab= &tracking->stabilization;
+
+ if(mat)
copy_m4_m4(stabmat, mat);
if((stab->flag&TRACKING_2D_STABILIZATION)==0) {
@@ -1390,10 +1428,10 @@
stab->scale= 1.f;
if(!stab->ok && stab->ibufok && stab->ibuf)
- stab->ibufok= stabelize_need_recalc(tracking, width,
height, firstmedian, curmedian, mat) == 0;
+ stab->ibufok= stabilize_need_recalc(tracking, width,
height, firstmedian, curmedian, mat) == 0;
if(!stab->ibuf || !stab->ibufok) {
- tmpibuf= stabelize_acquire_ibuf(stab->ibuf, ibuf, 1);
+ tmpibuf= stabilize_acquire_ibuf(stab->ibuf, ibuf, 1);
stab->ibuf= tmpibuf;
if(stab->flag&TRACKING_AUTOSCALE) {
@@ -1401,7 +1439,7 @@
stabilization_auto_scale_factor(tracking);
- scaleibuf=
stabelize_acquire_ibuf(stab->scaleibuf, ibuf, 0);
+ scaleibuf=
stabilize_acquire_ibuf(stab->scaleibuf, ibuf, 0);
stab->scaleibuf= scaleibuf;
IMB_rectcpy(scaleibuf, ibuf, 0, 0, 0, 0,
ibuf->x, ibuf->y);
Modified: branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
2011-07-29 20:46:30 UTC (rev 38827)
+++ branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
2011-07-29 20:55:23 UTC (rev 38828)
@@ -1080,6 +1080,11 @@
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
}
+static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C,
PointerRNA *ptr)
+{
+ uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
+}
+
/* only once called */
static void node_composit_set_butfunc(bNodeType *ntype)
{
@@ -1233,6 +1238,9 @@
case CMP_NODE_MOVIECLIP:
ntype->uifunc= node_composit_buts_movieclip;
break;
+ case CMP_NODE_STABILIZE2D:
+ ntype->uifunc= node_composit_buts_stabilize2d;
+ break;
default:
ntype->uifunc= NULL;
}
Modified:
branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
2011-07-29 20:46:30 UTC (rev 38827)
+++ branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
2011-07-29 20:55:23 UTC (rev 38828)
@@ -1423,7 +1423,7 @@
if(clip==NULL)
continue;
BKE_movieclip_user_set_frame(&bgpic->cuser,
CFRA);
- ibuf= BKE_movieclip_acquire_stable_ibuf(clip,
&bgpic->cuser, NULL);
+ ibuf= BKE_movieclip_acquire_ibuf(clip,
&bgpic->cuser);
/* working with ibuf from image and clip has
got different workflow now.
ibuf acquired from clip is referenced by
cache system and should
Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree.c
2011-07-29 20:46:30 UTC (rev 38827)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree.c
2011-07-29 20:55:23 UTC (rev 38828)
@@ -2282,7 +2282,19 @@
RNA_def_struct_sdna_from(srna, "MovieClipUser", "storage");
}
+static void def_cmp_stabilize2d(StructRNA *srna)
+{
+ PropertyRNA *prop;
+ prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "id");
+ RNA_def_property_struct_type(prop, "MovieClip");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Movie Clip", "");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
+
+
/* -- Texture Nodes ---------------------------------------------------------
*/
static void def_tex_output(StructRNA *srna)
Modified:
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree_types.h
===================================================================
---
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree_types.h
2011-07-29 20:46:30 UTC (rev 38827)
+++
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree_types.h
2011-07-29 20:55:23 UTC (rev 38828)
@@ -115,6 +115,7 @@
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs