[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40266] branches/soc-2011-tomato/source/ blender: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Fri Sep 16 16:47:32 CEST 2011
Revision: 40266
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40266
Author: nazgul
Date: 2011-09-16 14:47:32 +0000 (Fri, 16 Sep 2011)
Log Message:
-----------
Camera tracking integration
===========================
Implemented "Movie Distort" and "Movie Undistort" nodes which
uses camera undistortion coefficients.
Not perfect for footages shoted on cameras with pixel aspect != 1:
there's extra scaling down and scaling up caused by others areas supposing
frame aspect x be 1 and multiplying height by 1.0/pixel_aspect.
Not so critical but would be nice to solve.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
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/makesrna/intern/rna_nodetree.c
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree_types.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
branches/soc-2011-tomato/source/blender/nodes/CMakeLists.txt
branches/soc-2011-tomato/source/blender/nodes/NOD_composite.h
branches/soc-2011-tomato/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
branches/soc-2011-tomato/source/blender/nodes/composite/nodes/node_composite_transform.c
Added Paths:
-----------
branches/soc-2011-tomato/source/blender/nodes/composite/nodes/node_composite_moviedistort.c
branches/soc-2011-tomato/source/blender/nodes/composite/nodes/node_composite_movieundistort.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h 2011-09-16 14:45:32 UTC (rev 40265)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h 2011-09-16 14:47:32 UTC (rev 40266)
@@ -567,6 +567,8 @@
#define CMP_NODE_MOVIECLIP 262
#define CMP_NODE_STABILIZE2D 263
#define CMP_NODE_TRANSFORM 264
+#define CMP_NODE_MOVIEUNDISTORT 265
+#define CMP_NODE_MOVIEDISTORT 266
#define CMP_NODE_GLARE 301
#define CMP_NODE_TONEMAP 302
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c 2011-09-16 14:45:32 UTC (rev 40265)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c 2011-09-16 14:47:32 UTC (rev 40266)
@@ -1849,6 +1849,8 @@
register_node_type_cmp_lensdist(ntypelist);
register_node_type_cmp_transform(ntypelist);
register_node_type_cmp_stabilize2d(ntypelist);
+ register_node_type_cmp_moviedistort(ntypelist);
+ register_node_type_cmp_movieundistort(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-09-16 14:45:32 UTC (rev 40265)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-09-16 14:47:32 UTC (rev 40266)
@@ -1894,19 +1894,20 @@
{
ImBuf *resibuf;
MovieTrackingCamera *camera= &tracking->camera;
+ float aspy= 1.f/tracking->camera.pixel_aspect;
resibuf= IMB_dupImBuf(ibuf);
if(ibuf->rect_float) {
libmv_undistortFloat(camera->focal,
- camera->principal[0], camera->principal[1],
+ camera->principal[0], camera->principal[1] * aspy,
camera->k1, camera->k2, camera->k3,
ibuf->rect_float, resibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels);
ibuf->userflags|= IB_RECT_INVALID;
} else {
libmv_undistortByte(camera->focal,
- camera->principal[0], camera->principal[1],
+ camera->principal[0], camera->principal[1] * aspy,
camera->k1, camera->k2, camera->k3,
(unsigned char*)ibuf->rect, (unsigned char*)resibuf->rect, ibuf->x, ibuf->y, ibuf->channels);
}
@@ -1918,19 +1919,20 @@
{
ImBuf *resibuf;
MovieTrackingCamera *camera= &tracking->camera;
+ float aspy= 1.f/tracking->camera.pixel_aspect;
resibuf= IMB_dupImBuf(ibuf);
if(ibuf->rect_float) {
libmv_distortFloat(camera->focal,
- camera->principal[0], camera->principal[1],
+ camera->principal[0], camera->principal[1] * aspy,
camera->k1, camera->k2, camera->k3,
ibuf->rect_float, resibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels);
ibuf->userflags|= IB_RECT_INVALID;
} else {
libmv_distortByte(camera->focal,
- camera->principal[0], camera->principal[1],
+ camera->principal[0], camera->principal[1] * aspy,
camera->k1, camera->k2, camera->k3,
(unsigned char*)ibuf->rect, (unsigned char*)resibuf->rect, ibuf->x, ibuf->y, ibuf->channels);
}
Modified: branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c 2011-09-16 14:45:32 UTC (rev 40265)
+++ branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c 2011-09-16 14:47:32 UTC (rev 40266)
@@ -1695,6 +1695,17 @@
uiItemR(layout, ptr, "filter_type", 0, "", 0);
}
+static void node_composit_buts_movieundistort(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+ uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
+
+}
+
+static void node_composit_buts_moviedistort(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)
{
@@ -1854,6 +1865,12 @@
case CMP_NODE_TRANSFORM:
ntype->uifunc= node_composit_buts_transform;
break;
+ case CMP_NODE_MOVIEUNDISTORT:
+ ntype->uifunc= node_composit_buts_movieundistort;
+ break;
+ case CMP_NODE_MOVIEDISTORT:
+ ntype->uifunc= node_composit_buts_moviedistort;
+ break;
default:
ntype->uifunc= NULL;
}
Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree.c 2011-09-16 14:45:32 UTC (rev 40265)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree.c 2011-09-16 14:47:32 UTC (rev 40266)
@@ -2445,6 +2445,30 @@
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
}
+static void def_cmp_movieundistort(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");
+}
+
+static void def_cmp_moviedistort(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");
+}
+
static void dev_cmd_transform(StructRNA *srna)
{
PropertyRNA *prop;
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-09-16 14:45:32 UTC (rev 40265)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree_types.h 2011-09-16 14:47:32 UTC (rev 40266)
@@ -122,6 +122,8 @@
DefNode( CompositorNode, CMP_NODE_MOVIECLIP, def_cmp_movieclip, "MOVIECLIP", MovieClip, "MovieClip", "" )
DefNode( CompositorNode, CMP_NODE_TRANSFORM, dev_cmd_transform, "TRANSFORM", Transform, "Transform", "" )
DefNode( CompositorNode, CMP_NODE_STABILIZE2D, def_cmp_stabilize2d, "STABILIZE2D", Stabilize, "Stabelize 2D", "" )
+DefNode( CompositorNode, CMP_NODE_MOVIEDISTORT, def_cmp_moviedistort, "MOVIEDISTORT", MovieDistort, "Movie Distort", "" )
+DefNode( CompositorNode, CMP_NODE_MOVIEUNDISTORT, def_cmp_movieundistort, "MOVIEUNDISTORT", MovieUndistort, "Movie Undistort", "" )
DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" )
DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" )
Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c 2011-09-16 14:45:32 UTC (rev 40265)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c 2011-09-16 14:47:32 UTC (rev 40266)
@@ -376,19 +376,19 @@
RNA_def_property_float_sdna(prop, NULL, "k1");
RNA_def_property_ui_range(prop, -10, 10, .1, 3);
RNA_def_property_ui_text(prop, "K1", "");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_flushUpdate");
prop= RNA_def_property(srna, "k2", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "k2");
RNA_def_property_ui_range(prop, -10, 10, .1, 3);
RNA_def_property_ui_text(prop, "K2", "");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_flushUpdate");
prop= RNA_def_property(srna, "k3", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "k3");
RNA_def_property_ui_range(prop, -10, 10, .1, 3);
RNA_def_property_ui_text(prop, "K3", "");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_flushUpdate");
/* pixel aspect */
prop= RNA_def_property(srna, "pixel_aspect", PROP_FLOAT, PROP_XYZ);
@@ -396,7 +396,7 @@
RNA_def_property_range(prop, 0.1f, 5000.0f);
RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
RNA_def_property_ui_text(prop, "Pixel Aspect", "Pixel aspect ratio");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
}
static void rna_def_trackingMarker(BlenderRNA *brna)
Modified: branches/soc-2011-tomato/source/blender/nodes/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/source/blender/nodes/CMakeLists.txt 2011-09-16 14:45:32 UTC (rev 40265)
+++ branches/soc-2011-tomato/source/blender/nodes/CMakeLists.txt 2011-09-16 14:47:32 UTC (rev 40266)
@@ -81,6 +81,8 @@
composite/nodes/node_composite_math.c
composite/nodes/node_composite_mixrgb.c
composite/nodes/node_composite_movieclip.c
+ composite/nodes/node_composite_moviedistort.c
+ composite/nodes/node_composite_movieundistort.c
composite/nodes/node_composite_normal.c
composite/nodes/node_composite_normalize.c
composite/nodes/node_composite_outputFile.c
Modified: branches/soc-2011-tomato/source/blender/nodes/NOD_composite.h
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list