Camera tracking integration

===========================

- Removed TRACK_PROCESSED flag which is actually unneeded now.
- When libmv fails to track marker for next frame, add marker
  for new frame with old position and set it up as Disabled.
- "Break" track path when markers sequence is "broken".
  This means path wouldn't be drawed over frames, during which
  racking object was lost.
- Update Properties Editor for SpaceClip during playback.
  Track preview button should now update nicely.
This commit is contained in:
Sergey Sharybin 2011-07-02 16:03:47 +00:00
parent 9cabee006b
commit dc81327f75
4 changed files with 26 additions and 16 deletions

@ -553,7 +553,7 @@ void BKE_tracking_sync(MovieTrackingContext *context)
if(sel_type==MCLIP_SEL_TRACK && sel==cur)
replace_sel= 1;
track->flag= cur->flag | (track->flag&TRACK_PROCESSED);
track->flag= cur->flag;
track->pat_flag= cur->pat_flag;
track->search_flag= cur->search_flag;
@ -635,6 +635,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
double x1= pos[0], y1= pos[1];
double x2= x1, y2= y1;
int wndx, wndy;
MovieTrackingMarker marker_new;
wndx= (int)((track->pat_max[0]-track->pat_min[0])*ibuf->x)/2;
wndy= (int)((track->pat_max[1]-track->pat_min[1])*ibuf->y)/2;
@ -642,8 +643,6 @@ int BKE_tracking_next(MovieTrackingContext *context)
if(libmv_regionTrackerTrack(context->region_tracker, patch, patch_new,
width, height, MAX2(wndx, wndy),
x1, y1, &x2, &y2)) {
MovieTrackingMarker marker_new;
memset(&marker_new, 0, sizeof(marker_new));
marker_new.pos[0]= (origin[0]+x2)/ibuf_new->x;
marker_new.pos[1]= (origin[1]+y2)/ibuf_new->y;
@ -651,18 +650,22 @@ int BKE_tracking_next(MovieTrackingContext *context)
if(context->backwards) marker_new.framenr= curfra-1;
else marker_new.framenr= curfra+1;
track->flag|= TRACK_PROCESSED;
BKE_tracking_insert_marker(track, &marker_new);
ok= 1;
} else {
marker_new= *marker;
marker_new.framenr++;
marker_new.flag|= MARKER_DISABLED;
BKE_tracking_insert_marker(track, &marker_new);
}
ok= 1;
MEM_freeN(patch);
MEM_freeN(patch_new);
#endif
} else
track->flag|= TRACK_PROCESSED;
}
track= track->next;
}

@ -2778,6 +2778,15 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws)
}
}
else if(regiontype==RGN_TYPE_UI) {
if(spacetype==SPACE_CLIP) {
/* Track Preview button is on Properties Editor in SpaceClip,
and it's very common case when users want it be refreshing
during playback, so asking people to enable special option
for this is a bit ticky, so add exception here for refreshing
Properties Editor for SpaceClip always */
return 1;
}
if(redraws & TIME_ALL_BUTS_WIN)
return 1;
}

@ -175,12 +175,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *clip, MovieTrackingTrack *
BKE_movieclip_last_selection(clip, &sel_type, &sel);
/* non-tracked tracks shouldn't display path */
if((track->flag&TRACK_PROCESSED)==0)
return;
marker= BKE_tracking_get_marker(track, sc->user.framenr);
if(marker->flag&MARKER_DISABLED)
if(marker->framenr!=sc->user.framenr || marker->flag&MARKER_DISABLED)
return;
framenr= marker->framenr;
@ -198,7 +194,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *clip, MovieTrackingTrack *
if(marker->framenr==sc->user.framenr)
curindex= a;
}
} else
break;
i--;
}
@ -216,7 +213,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *clip, MovieTrackingTrack *
curindex= b;
copy_v2_v2(path[b++], marker->pos);
}
} else
break;
i++;
}

@ -109,7 +109,7 @@ typedef struct MovieTracking {
#define MARKER_DISABLED 1
/* MovieTrackingTrack->flag */
#define TRACK_PROCESSED (1<<1)
#define TRACK_UNUSED (1<<1)
#define TRACK_DISABLE_RED (1<<2)
#define TRACK_DISABLE_GREEN (1<<3)
#define TRACK_DISABLE_BLUE (1<<4)