[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40914] branches/soc-2011-tomato/source/ blender: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Mon Oct 10 17:29:39 CEST 2011
Revision: 40914
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40914
Author: nazgul
Date: 2011-10-10 15:29:39 +0000 (Mon, 10 Oct 2011)
Log Message:
-----------
Camera tracking integration
===========================
- Fixed movie clip cache drawing -- it used to draw both
distorted and undistorted cached frames.
- Undistort markers position in clip editor when using
undistorted rendering.
Can be noticeable slower when displaying paths.
- Display proper image in track preview widget when
using undistorted rendering.
- Do not mark scoped as dirty when not in tracking mode.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.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/space_clip.c
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h 2011-10-10 15:29:31 UTC (rev 40913)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h 2011-10-10 15:29:39 UTC (rev 40914)
@@ -44,7 +44,7 @@
struct ImBuf;
struct MovieCache;
-typedef void (*MovieCacheGetKeyDataFP) (void *userkey, int *framenr, int *proxy);
+typedef void (*MovieCacheGetKeyDataFP) (void *userkey, int *framenr, int *proxy, int *render_flags);
void BKE_moviecache_init(void);
void BKE_moviecache_destruct(void);
@@ -53,6 +53,6 @@
void BKE_moviecache_put(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf);
struct ImBuf* BKE_moviecache_get(struct MovieCache *cache, void *userkey);
void BKE_moviecache_free(struct MovieCache *cache);
-void BKE_moviecache_get_cache_segments(struct MovieCache *cache, int proxy, int *totseg_r, int **points_r);
+void BKE_moviecache_get_cache_segments(struct MovieCache *cache, int proxy, int render_flags, int *totseg_r, int **points_r);
#endif
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c 2011-10-10 15:29:31 UTC (rev 40913)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c 2011-10-10 15:29:39 UTC (rev 40914)
@@ -58,7 +58,7 @@
int keysize;
unsigned long curtime;
- int totseg, *points, points_proxy; /* for visual statistics optimization */
+ int totseg, *points, proxy, render_flags; /* for visual statistics optimization */
int pad;
} MovieCache;
@@ -212,7 +212,7 @@
cache->hashfp= hashfp;
cache->cmpfp= cmpfp;
cache->getdatafp= getdatafp;
- cache->points_proxy= -1;
+ cache->proxy= -1;
return cache;
}
@@ -294,7 +294,7 @@
}
/* get segments of cached frames. useful for debugging cache policies */
-void BKE_moviecache_get_cache_segments(MovieCache *cache, int proxy, int *totseg_r, int **points_r)
+void BKE_moviecache_get_cache_segments(MovieCache *cache, int proxy, int render_flags, int *totseg_r, int **points_r)
{
*totseg_r= 0;
*points_r= NULL;
@@ -302,7 +302,7 @@
if(!cache->getdatafp)
return;
- if(cache->points_proxy!=proxy) {
+ if(cache->proxy!=proxy || cache->render_flags!=render_flags) {
if(cache->points)
MEM_freeN(cache->points);
@@ -323,12 +323,12 @@
while(!BLI_ghashIterator_isDone(iter)) {
MovieCacheKey *key= BLI_ghashIterator_getKey(iter);
MovieCacheItem *item= BLI_ghashIterator_getValue(iter);
- int framenr, curproxy;
+ int framenr, curproxy, curflags;
if(item->ibuf) {
- cache->getdatafp(key->userkey, &framenr, &curproxy);
+ cache->getdatafp(key->userkey, &framenr, &curproxy, &curflags);
- if(curproxy==proxy)
+ if(curproxy==proxy && curflags==render_flags)
frames[a++]= framenr;
}
@@ -374,6 +374,8 @@
cache->totseg= totseg;
cache->points= points;
+ cache->proxy= proxy;
+ cache->render_flags= render_flags;
}
}
}
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2011-10-10 15:29:31 UTC (rev 40913)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2011-10-10 15:29:39 UTC (rev 40914)
@@ -284,12 +284,13 @@
short render_flag;
} MovieClipImBufCacheKey;
-static void moviecache_keydata(void *userkey, int *framenr, int *proxy)
+static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags)
{
MovieClipImBufCacheKey *key= (MovieClipImBufCacheKey*)userkey;
*framenr= key->framenr;
*proxy= key->proxy;
+ *render_flags= key->render_flag;
}
static unsigned int moviecache_hashhash(const void *keyv)
@@ -610,7 +611,6 @@
if(ibuf) {
clip->lastframe= framenr;
-
real_ibuf_size(clip, user, ibuf, &clip->lastsize[0], &clip->lastsize[1]);
/* put undistorted frame to cache */
@@ -637,7 +637,7 @@
BLI_lock_thread(LOCK_MOVIECLIP);
/* try to obtain cached undistorted image first */
- if(need_undistorted_cache(user, clip->flag)) {
+ if(need_undistorted_cache(user, flag)) {
ibuf= get_undistorted_cache(clip, user);
if(!ibuf)
cache_undistorted= 1;
@@ -792,7 +792,7 @@
if(clip->cache) {
int proxy= rendersize_to_proxy(user, clip->flag);
- BKE_moviecache_get_cache_segments(clip->cache->moviecache, proxy, totseg_r, points_r);
+ BKE_moviecache_get_cache_segments(clip->cache->moviecache, proxy, user->render_flag, totseg_r, points_r);
}
}
@@ -889,9 +889,25 @@
if(ibuf && ibuf->rect) {
ImBuf *tmpibuf;
+ MovieTrackingMarker undist_marker= *marker;
- tmpibuf= BKE_tracking_acquire_pattern_imbuf(ibuf, track, marker, 1, 1, scopes->track_pos, NULL);
+ if(user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT) {
+ int width, height;
+ float aspy= 1.f/clip->tracking.camera.pixel_aspect;;
+ BKE_movieclip_acquire_size(clip, user, &width, &height);
+
+ undist_marker.pos[0]*= width;
+ undist_marker.pos[1]*= height*aspy;
+
+ BKE_tracking_invert_intrinsics(&clip->tracking, undist_marker.pos, undist_marker.pos);
+
+ undist_marker.pos[0]/= width;
+ undist_marker.pos[1]/= height*aspy;
+ }
+
+ tmpibuf= BKE_tracking_acquire_pattern_imbuf(ibuf, track, &undist_marker, 1, 1, scopes->track_pos, NULL);
+
if(tmpibuf->rect_float)
IMB_rect_from_float(tmpibuf);
Modified: branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h 2011-10-10 15:29:31 UTC (rev 40913)
+++ branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h 2011-10-10 15:29:39 UTC (rev 40914)
@@ -56,6 +56,7 @@
void ED_clip_update_frame(const struct Main *mainp, int cfra);
void ED_clip_view_selection(struct SpaceClip *sc, struct ARegion *ar, int fit);
+void ED_clip_point_undistorted_pos(SpaceClip *sc, float co[2], float nco[2]);
void ED_clip_point_stable_pos(struct bContext *C, float x, float y, float *xr, float *yr);
void ED_clip_mouse_pos(struct bContext *C, struct wmEvent *event, float co[2]);
Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2011-10-10 15:29:31 UTC (rev 40913)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2011-10-10 15:29:39 UTC (rev 40914)
@@ -274,6 +274,7 @@
if(marker->framenr==i) {
add_v2_v2v2(path[--a], marker->pos, track->offset);
+ ED_clip_point_undistorted_pos(sc, path[a], path[a]);
if(marker->framenr==sc->user.framenr)
curindex= a;
@@ -296,6 +297,7 @@
curindex= b;
add_v2_v2v2(path[b++], marker->pos, track->offset);
+ ED_clip_point_undistorted_pos(sc, path[b-1], path[b-1]);
} else
break;
@@ -351,7 +353,7 @@
glPointSize(1.0f);
}
-static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, int width, int height)
+static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int width, int height)
{
int tiny= sc->flag&SC_SHOW_TINY_MARKER;
int show_search= 0;
@@ -369,7 +371,9 @@
BLI_init_rctf(&r, track->pat_min[0], track->pat_max[0], track->pat_min[1], track->pat_max[1]);
add_v2_v2v2(pos, marker->pos, track->offset);
- if(BLI_in_rctf(&r, pos[0]-marker->pos[0], pos[1]-marker->pos[1])) {
+ ED_clip_point_undistorted_pos(sc, pos, pos);
+
+ if(BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) {
if(tiny) glPointSize(3.0f);
else glPointSize(4.0f);
glBegin(GL_POINTS);
@@ -397,7 +401,7 @@
/* pattern and search outline */
glPushMatrix();
- glTranslatef(marker->pos[0], marker->pos[1], 0);
+ glTranslatef(marker_pos[0], marker_pos[1], 0);
if(!tiny) glLineWidth(3.0f);
@@ -439,7 +443,7 @@
}
}
-static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, int width, int height, int act, int sel)
+static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int width, int height, int act, int sel)
{
int tiny= sc->flag&SC_SHOW_TINY_MARKER;
int show_search= 0;
@@ -464,12 +468,11 @@
else glColor3fv(col);
}
- add_v2_v2v2(pos, marker->pos, track->offset);
-
BLI_init_rctf(&r, track->pat_min[0], track->pat_max[0], track->pat_min[1], track->pat_max[1]);
add_v2_v2v2(pos, marker->pos, track->offset);
+ ED_clip_point_undistorted_pos(sc, pos, pos);
- if(BLI_in_rctf(&r, pos[0]-marker->pos[0], pos[1]-marker->pos[1])) {
+ if(BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) {
if(!tiny) glPointSize(2.0f);
glBegin(GL_POINTS);
glVertex2f(pos[0], pos[1]);
@@ -498,7 +501,7 @@
glBegin(GL_LINES);
glVertex2fv(pos);
- glVertex2fv(marker->pos);
+ glVertex2fv(marker_pos);
glEnd();
glDisable(GL_COLOR_LOGIC_OP);
@@ -508,7 +511,7 @@
/* pattern */
glPushMatrix();
- glTranslatef(marker->pos[0], marker->pos[1], 0);
+ glTranslatef(marker_pos[0], marker_pos[1], 0);
if(tiny) {
glLineStipple(3, 0xaaaa);
@@ -569,7 +572,8 @@
glPopMatrix();
}
-static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, int outline, int sel, int act, int width, int height)
+static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ float marker_pos[2], int outline, int sel, int act, int width, int height)
{
float x, y, dx, dy, patdx, patdy, searchdx, searchdy, tdx, tdy;
int tiny= sc->flag&SC_SHOW_TINY_MARKER;
@@ -589,7 +593,7 @@
}
glPushMatrix();
- glTranslatef(marker->pos[0], marker->pos[1], 0);
+ glTranslatef(marker_pos[0], marker_pos[1], 0);
dx= 6.0f/width/sc->zoom;
dy= 6.0f/height/sc->zoom;
@@ -697,7 +701,7 @@
glLineWidth(1.0f);
}
-static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, int act,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list