diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-02-22 14:13:15 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-02-22 14:13:15 +0400 |
commit | ca689e88aac0e33bf0fd9701f5c6174b5ff5f3fd (patch) | |
tree | 4ac995bce7fee0b4b8fd44c21c5efec767a98a68 /source/blender/blenkernel/intern/tracking.c | |
parent | 4cf9034f6d59840f8312094c184b9708a251fe0a (diff) |
Motion tracking dopesheet
Highlight background depending on number of tracks existing on frame.
This is not so much mathematically accurate displaying where things
shall be improved, but it's nice feedback about which frames better
be reviewed.
Bad frames are tracks < 8, highlighted with red.
OK-ish frame are 8 <= tracks < 16, highlighted with yellow.
Could be some artifacts with color region start/end, this is a bit
unclear what exactly expected to be highlighted -- frames are
displayed as dots, but in fact they're quite noticeable segments.
---
svn merge -r54572:54573 ^/branches/soc-2011-tomato
Diffstat (limited to 'source/blender/blenkernel/intern/tracking.c')
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index a6519f8005c..1a7458f531c 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -141,8 +141,10 @@ static void tracking_dopesheet_free(MovieTrackingDopesheet *dopesheet) } BLI_freelistN(&dopesheet->channels); + BLI_freelistN(&dopesheet->coverage_segments); dopesheet->channels.first = dopesheet->channels.last = NULL; + dopesheet->coverage_segments.first = dopesheet->coverage_segments.last = NULL; dopesheet->tot_channel = 0; } @@ -3784,6 +3786,88 @@ static void tracking_dopesheet_sort(MovieTracking *tracking, int sort_method, in } } +static int coverage_from_count(int count) +{ + if (count < 8) + return TRACKING_COVERAGE_BAD; + else if (count < 16) + return TRACKING_COVERAGE_ACCEPTABLE; + return TRACKING_COVERAGE_OK; +} + +static void tracking_dopesheet_calc_coverage(MovieTracking *tracking) +{ + MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; + MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); + ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object); + MovieTrackingTrack *track; + int frames, start_frame = INT_MAX, end_frame = -INT_MAX; + int *per_frame_counter; + int prev_coverage, last_segment_frame; + int i; + + /* find frame boundaries */ + for (track = tracksbase->first; track; track = track->next) { + start_frame = min_ii(start_frame, track->markers[0].framenr); + end_frame = max_ii(end_frame, track->markers[track->markersnr - 1].framenr); + } + + frames = end_frame - start_frame + 1; + + /* this is a per-frame counter of markers (how many markers belongs to the same frame) */ + per_frame_counter = MEM_callocN(sizeof(int) * frames, "per frame track counter"); + + /* find per-frame markers count */ + for (track = tracksbase->first; track; track = track->next) { + int i; + + for (i = 0; i < track->markersnr; i++) { + MovieTrackingMarker *marker = &track->markers[i]; + + /* TODO: perhaps we need to add check for non-single-frame track here */ + if ((marker->flag & MARKER_DISABLED) == 0) + per_frame_counter[marker->framenr - start_frame]++; + } + } + + /* convert markers count to coverage and detect segments with the same coverage */ + prev_coverage = coverage_from_count(per_frame_counter[0]); + last_segment_frame = start_frame; + + /* means only disabled tracks in the beginning, could be ignored */ + if (!per_frame_counter[0]) + prev_coverage = TRACKING_COVERAGE_OK; + + for (i = 1; i < frames; i++) { + int coverage = coverage_from_count(per_frame_counter[i]); + + /* means only disabled tracks in the end, could be ignored */ + if (i == frames - 1 && !per_frame_counter[i]) + coverage = TRACKING_COVERAGE_OK; + + if (coverage != prev_coverage || i == frames - 1) { + MovieTrackingDopesheetCoverageSegment *coverage_segment; + int end_segment_frame = i - 1 + start_frame; + + if (end_segment_frame == last_segment_frame) + end_segment_frame++; + + coverage_segment = MEM_callocN(sizeof(MovieTrackingDopesheetCoverageSegment), "tracking coverage segment"); + coverage_segment->coverage = prev_coverage; + coverage_segment->start_frame = last_segment_frame; + coverage_segment->end_frame = end_segment_frame; + + BLI_addtail(&dopesheet->coverage_segments, coverage_segment); + + last_segment_frame = end_segment_frame; + } + + prev_coverage = coverage; + } + + MEM_freeN(per_frame_counter); +} + void BKE_tracking_dopesheet_tag_update(MovieTracking *tracking) { MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; @@ -3811,6 +3895,7 @@ void BKE_tracking_dopesheet_update(MovieTracking *tracking) reconstruction = BKE_tracking_object_get_reconstruction(tracking, object); + /* channels */ for (track = tracksbase->first; track; track = track->next) { MovieTrackingDopesheetChannel *channel; @@ -3838,5 +3923,8 @@ void BKE_tracking_dopesheet_update(MovieTracking *tracking) tracking_dopesheet_sort(tracking, sort_method, inverse); + /* frame coverage */ + tracking_dopesheet_calc_coverage(tracking); + dopesheet->ok = TRUE; } |