[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38899] branches/soc-2011-tomato: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Mon Aug 1 17:28:19 CEST 2011
Revision: 38899
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38899
Author: nazgul
Date: 2011-08-01 15:28:19 +0000 (Mon, 01 Aug 2011)
Log Message:
-----------
Camera tracking integration
===========================
- Do not show frame boundary border when stabilization isn't enabled.
- Separate stabilization settings from display in clip editor.
Now clip can contain stabilization data but still be displayed
un-stabilized in clip editor.
- Internal changes in stabilization:
* Use separated location/scale parameters rather than 4x4 matrix.
In some ares "decomposed" data is needed (text draw functions, i.e.).
Also such decomposed data could be used in compositor.
* MovieClip now uses own structure for cache where additional data
can be stored. MovieCache structure now one of properties in
this new structure.
* Get rid of stable image buffer stored in MovieClipStabilization
structure. Pre-created buffer for scaling still stored there.
This helps to keep playback realtime -- re-creating this buffer
introduces ~15% slowdown.
- Added sliders to 2D stabilization panel which controls intensity
of translation/scale which applies on shot.
- Added filter type to Stabilize2D compositor node. Supports nearest,
bilinear and bicubic interpolation.
- After discussion with Sebastian and Francois added new node called
Transformation. It can apply translation, rotation and scale. It's
not the same thing as applying this components separately -- all
transformation is happening inside "canvas". And it should be more
accurate on interpolation and sub-pixel translation.
Need to check order of applying translation/scale/rotation btw.
- Added output sockets to movie clip compositor node. They holds
stabilization data which can be used by Translate or Transform
nodes.
- Minor fix of UI issues in Display panel.
Modified Paths:
--------------
branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h
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/blenloader/intern/readfile.c
branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_ops.c
branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h
branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h
branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h
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_space.c
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
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
branches/soc-2011-tomato/source/blender/nodes/intern/CMP_nodes/CMP_scale.c
branches/soc-2011-tomato/source/blender/nodes/intern/CMP_nodes/CMP_stabilize2d.c
branches/soc-2011-tomato/source/blender/nodes/intern/CMP_util.h
Added Paths:
-----------
branches/soc-2011-tomato/source/blender/nodes/intern/CMP_nodes/CMP_transform.c
Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2011-08-01 15:24:15 UTC (rev 38898)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2011-08-01 15:28:19 UTC (rev 38899)
@@ -328,8 +328,9 @@
row = layout.row()
row.prop(sc, "show_track_path", text="Path")
- row.active = sc.show_track_path
- row.prop(sc, "path_length", text="Length")
+ sub = row.column()
+ sub.active = sc.show_track_path
+ sub.prop(sc, "path_length", text="Length")
row = layout.row()
row.prop(sc, "show_disabled", text="Disabled")
@@ -339,7 +340,9 @@
row.prop(sc, "show_names", text="Names")
row.prop(sc, "show_grid", text="Grid")
- layout.prop(sc, "show_tiny_markers", text="Tiny Markers")
+ row = layout.row()
+ row.prop(sc, "show_tiny_markers", text="Tiny Markers")
+ row.prop(sc, "show_stable", text="Stable")
layout.prop(sc, "lock_selection")
layout.prop(sc, "use_mute_footage")
@@ -377,7 +380,6 @@
layout.active = stab.use_2d_stabilization
- layout.prop(stab, "use_autoscale")
row = layout.row()
row.template_list(stab, "tracks", stab, "active_track_index", rows=3)
@@ -387,7 +389,14 @@
sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="")
sub.menu('CLIP_MT_stabilize_2d_specials', text="", icon="DOWNARROW_HLT")
+ layout.prop(stab, "influence_location")
+ layout.prop(stab, "use_autoscale")
+ row = layout.row()
+ row.active = stab.use_autoscale
+ row.prop(stab, "influence_scale")
+
+
class CLIP_PT_footage(bpy.types.Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h 2011-08-01 15:24:15 UTC (rev 38898)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h 2011-08-01 15:28:19 UTC (rev 38899)
@@ -48,7 +48,7 @@
void BKE_movieclip_reload(struct MovieClip *clip);
struct ImBuf *BKE_movieclip_acquire_ibuf(struct MovieClip *clip, struct MovieClipUser *user);
-struct ImBuf *BKE_movieclip_acquire_stable_ibuf(struct MovieClip *clip, struct MovieClipUser *user, float mat[4][4]);
+struct ImBuf *BKE_movieclip_acquire_stable_ibuf(struct MovieClip *clip, struct MovieClipUser *user, float loc[2], float *scale);
void BKE_movieclip_acquire_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height);
int BKE_movieclip_has_frame(struct MovieClip *clip, struct MovieClipUser *user);
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr);
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h 2011-08-01 15:24:15 UTC (rev 38898)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h 2011-08-01 15:28:19 UTC (rev 38899)
@@ -389,6 +389,7 @@
#define CMP_NODE_HUECORRECT 261
#define CMP_NODE_MOVIECLIP 262
#define CMP_NODE_STABILIZE2D 263
+#define CMP_NODE_TRANSFORM 264
#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-08-01 15:24:15 UTC (rev 38898)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h 2011-08-01 15:28:19 UTC (rev 38899)
@@ -87,8 +87,9 @@
struct MovieTrackingTrack *BKE_tracking_indexed_bundle(struct MovieTracking *tracking, int bundlenr);
-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]);
+void BKE_tracking_stabilization_data(struct MovieTracking *tracking, int framenr, int width, int height, float loc[2], float *scale);
+struct ImBuf *BKE_tracking_stabilize_shot(struct MovieTracking *tracking, int framenr, struct ImBuf *ibuf, float loc[2], float *scale);
+void BKE_tracking_stabdata_to_mat4(float loc[2], float scale, 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-08-01 15:24:15 UTC (rev 38898)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2011-08-01 15:28:19 UTC (rev 38899)
@@ -151,6 +151,16 @@
/*********************** image buffer cache *************************/
+typedef struct MovieClipCache {
+ /* regular moive cache */
+ struct MovieCache *moviecache;
+
+ /* cache for stable shot */
+ int stable_framenr;
+ float stable_loc[2], stable_scale;
+ ImBuf *stableibuf;
+} MovieClipCache;
+
typedef struct MovieClipImBufCacheKey {
int framenr;
} MovieClipImBufCacheKey;
@@ -183,11 +193,11 @@
static ImBuf *get_imbuf_cache(MovieClip *clip, MovieClipUser *user)
{
- if(clip->ibuf_cache) {
+ if(clip->cache) {
MovieClipImBufCacheKey key;
key.framenr= user?user->framenr:clip->lastframe;
- return BKE_moviecache_get(clip->ibuf_cache, &key);
+ return BKE_moviecache_get(clip->cache->moviecache, &key);
}
return NULL;
@@ -197,14 +207,16 @@
{
MovieClipImBufCacheKey key;
- if(!clip->ibuf_cache) {
- clip->ibuf_cache= BKE_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash,
+ if(!clip->cache) {
+ clip->cache= MEM_callocN(sizeof(MovieClipCache), "movieClipCache");
+
+ clip->cache->moviecache= BKE_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash,
moviecache_hashcmp, moviecache_keydata);
}
key.framenr= user?user->framenr:clip->lastframe;
- BKE_moviecache_put(clip->ibuf_cache, &key, ibuf);
+ BKE_moviecache_put(clip->cache->moviecache, &key, ibuf);
}
/*********************** common functions *************************/
@@ -227,6 +239,9 @@
clip->tracking.settings.keyframe2= 30;
clip->tracking.settings.dist= 1;
+ clip->tracking.stabilization.scaleinf= 1.f;
+ clip->tracking.stabilization.locinf= 1.f;
+
return clip;
}
@@ -322,25 +337,45 @@
return ibuf;
}
-ImBuf *BKE_movieclip_acquire_stable_ibuf(MovieClip *clip, MovieClipUser *user, float mat[4][4])
+ImBuf *BKE_movieclip_acquire_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale)
{
- ImBuf *ibuf, *stableibuf;
+ ImBuf *ibuf, *stableibuf= NULL;
int framenr= user?user->framenr:clip->lastframe;
ibuf= BKE_movieclip_acquire_ibuf(clip, user);
if(clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) {
- MovieTrackingStabilization *stab= &clip->tracking.stabilization;
+ float tloc[2], tscale;
- if(user->framenr!=stab->framenr)
- stab->ibufok= 0;
+ if(clip->cache->stableibuf && clip->cache->stable_framenr==framenr) {
+ stableibuf= clip->cache->stableibuf;
- stableibuf= BKE_tracking_stabilize_shot(&clip->tracking, framenr, ibuf, mat);
+ BKE_tracking_stabilization_data(&clip->tracking, framenr, stableibuf->x, stableibuf->y, tloc, &tscale);
- stab->framenr= user->framenr;
+ if(!equals_v2v2(tloc, clip->cache->stable_loc) || tscale!=clip->cache->stable_scale) {
+ stableibuf= NULL;
+ }
+ }
+
+ if(!stableibuf) {
+ if(clip->cache->stableibuf)
+ IMB_freeImBuf(clip->cache->stableibuf);
+
+ stableibuf= BKE_tracking_stabilize_shot(&clip->tracking, framenr, ibuf, tloc, &tscale);
+
+ copy_v2_v2(clip->cache->stable_loc, tloc);
+ clip->cache->stable_scale= tscale;
+ clip->cache->stable_framenr= framenr;
+ clip->cache->stableibuf= stableibuf;
+ }
+
+ IMB_refImBuf(stableibuf);
+
+ if(loc) copy_v2_v2(loc, tloc);
+ if(scale) *scale= tscale;
} else {
- if(mat)
- unit_m4(mat);
+ if(loc) zero_v2(loc);
+ if(scale) *scale= 1.f;
stableibuf= ibuf;
}
@@ -393,8 +428,8 @@
*totseg_r= 0;
*points_r= NULL;
- if(clip->ibuf_cache)
- BKE_moviecache_get_cache_segments(clip->ibuf_cache, totseg_r, points_r);
+ if(clip->cache)
+ BKE_moviecache_get_cache_segments(clip->cache->moviecache, totseg_r, points_r);
}
void BKE_movieclip_user_set_frame(MovieClipUser *iuser, int framenr)
@@ -406,9 +441,14 @@
static void free_buffers(MovieClip *clip)
{
- if(clip->ibuf_cache) {
- BKE_moviecache_free(clip->ibuf_cache);
- clip->ibuf_cache= NULL;
+ if(clip->cache) {
+ BKE_moviecache_free(clip->cache->moviecache);
+
+ if(clip->cache->stableibuf)
+ IMB_freeImBuf(clip->cache->stableibuf);
+
+ MEM_freeN(clip->cache);
+ clip->cache= NULL;
}
if(clip->anim) {
@@ -423,7 +463,6 @@
free_buffers(clip);
clip->tracking.stabilization.ok= 0;
- clip->tracking.stabilization.ibufok= 0;
/* update clip source */
if(BLI_testextensie_array(clip->name, imb_ext_movie)) clip->source= MCLIP_SRC_MOVIE;
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c 2011-08-01 15:24:15 UTC (rev 38898)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c 2011-08-01 15:28:19 UTC (rev 38899)
@@ -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_transform(ntypelist);
register_node_type_cmp_stabilize2d(ntypelist);
}
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-08-01 15:24:15 UTC (rev 38898)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list