diff options
-rw-r--r-- | extern/libmv/libmv-capi.cpp | 8 | ||||
-rw-r--r-- | extern/libmv/libmv-capi.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_tracking.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 29 |
4 files changed, 33 insertions, 10 deletions
diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp index ffa065f08fe..8751e1e190b 100644 --- a/extern/libmv/libmv-capi.cpp +++ b/extern/libmv/libmv-capi.cpp @@ -357,8 +357,8 @@ void libmv_regionTrackerDestroy(libmv_RegionTracker *libmv_tracker) /* TrackRegion (new planar tracker) */ int libmv_trackRegion(const struct libmv_trackRegionOptions *options, - const float *image1, const float *image2, - int width, int height, + const float *image1, int image1_width, int image1_height, + const float *image2, int image2_width, int image2_height, const double *x1, const double *y1, struct libmv_trackRegionResult *result, double *x2, double *y2) @@ -400,8 +400,8 @@ int libmv_trackRegion(const struct libmv_trackRegionOptions *options, /* Convert from raw float buffers to libmv's FloatImage. */ libmv::FloatImage old_patch, new_patch; - floatBufToImage(image1, width, height, 1, &old_patch); - floatBufToImage(image2, width, height, 1, &new_patch); + floatBufToImage(image1, image1_width, image1_height, 1, &old_patch); + floatBufToImage(image2, image2_width, image2_height, 1, &new_patch); libmv::TrackRegionResult track_region_result; libmv::TrackRegion(old_patch, new_patch, xx1, yy1, track_region_options, xx2, yy2, &track_region_result); diff --git a/extern/libmv/libmv-capi.h b/extern/libmv/libmv-capi.h index 6f4b5dea384..fe759b06fe4 100644 --- a/extern/libmv/libmv-capi.h +++ b/extern/libmv/libmv-capi.h @@ -65,8 +65,8 @@ struct libmv_trackRegionResult { double correlation; }; int libmv_trackRegion(const struct libmv_trackRegionOptions *options, - const float *image1, const float *image2, - int width, int height, + const float *image1, int image1_width, int image1_height, + const float *image2, int image2_width, int image2_height, const double *x1, const double *y1, struct libmv_trackRegionResult *result, double *x2, double *y2); 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) { |