diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-06-11 15:40:54 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-06-11 15:40:54 +0400 |
commit | 6ab087ff994fab9557d99a4ba58393c7821b228c (patch) | |
tree | 38329b25a3dc70d37ac349241aeb42d6d9a1cbb9 /source | |
parent | 6674106d30a010c590aec1e7ab0b929155bde2bd (diff) |
Scale search area when doing planar tracking
Helps keeping features tracked when there's large scale happens
without need to manually re-adjust search area.
Currently using factor of pattern's boundbox scale, but probably
could be done in more accurate way?
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_tracking.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 29 |
2 files changed, 27 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index a13674cd6e5..716b65408e1 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -57,7 +57,7 @@ struct MovieTrackingMarker *BKE_tracking_insert_marker(struct MovieTrackingTrack struct MovieTrackingMarker *marker); void BKE_tracking_delete_marker(struct MovieTrackingTrack *track, int framenr); -void BKE_tracking_marker_pattern_minmax(struct MovieTrackingMarker *marker, float min[2], float max[2]); +void BKE_tracking_marker_pattern_minmax(const struct MovieTrackingMarker *marker, float min[2], float max[2]); struct MovieTrackingMarker *BKE_tracking_get_marker(struct MovieTrackingTrack *track, int framenr); struct MovieTrackingMarker *BKE_tracking_ensure_marker(struct MovieTrackingTrack *track, int framenr); struct MovieTrackingMarker *BKE_tracking_exact_marker(struct MovieTrackingTrack *track, int framenr); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index a3d66012303..4cfa8461f2e 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -440,7 +440,7 @@ void BKE_tracking_delete_marker(MovieTrackingTrack *track, int framenr) } } -void BKE_tracking_marker_pattern_minmax(MovieTrackingMarker *marker, float min[2], float max[2]) +void BKE_tracking_marker_pattern_minmax(const MovieTrackingMarker *marker, float min[2], float max[2]) { INIT_MINMAX2(min, max); @@ -1606,6 +1606,25 @@ static ImBuf *get_adjust_ibuf(MovieTrackingContext *context, MovieTrackingTrack return ibuf; } +static void marker_search_scale_after_tracking(const MovieTrackingMarker *old_marker, MovieTrackingMarker *new_marker) +{ + float old_pat_min[2], old_pat_max[2]; + float new_pat_min[2], new_pat_max[2]; + float scale_x, scale_y; + + BKE_tracking_marker_pattern_minmax(old_marker, old_pat_min, old_pat_max); + BKE_tracking_marker_pattern_minmax(new_marker, new_pat_min, new_pat_max); + + scale_x = (new_pat_max[0] - new_pat_min[0]) / (old_pat_max[0] - old_pat_min[0]); + scale_y = (new_pat_max[1] - new_pat_min[1]) / (old_pat_max[1] - old_pat_min[1]); + + new_marker->search_min[0] *= scale_x; + new_marker->search_min[1] *= scale_y; + + new_marker->search_max[0] *= scale_x; + new_marker->search_max[1] *= scale_y; +} + #endif void BKE_tracking_sync(MovieTrackingContext *context) @@ -1752,8 +1771,10 @@ int BKE_tracking_next(MovieTrackingContext *context) /* Run the tracker! */ tracked = libmv_trackRegion(&options, - track_context->search_area, patch_new, - width, height, + track_context->search_area, + track_context->search_area_width, + track_context->search_area_height, + patch_new, width, height, src_pixel_x, src_pixel_y, &result, dst_pixel_x, dst_pixel_y); @@ -1767,6 +1788,8 @@ int BKE_tracking_next(MovieTrackingContext *context) marker_new.flag |= MARKER_TRACKED; marker_new.framenr = nextfra; + marker_search_scale_after_tracking(marker, &marker_new); + #pragma omp critical { if (context->first_time) { |