diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-03-04 22:30:48 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-03-04 22:30:48 +0400 |
commit | 495aa863aeb54886a7f5ddc5c2716828fac53856 (patch) | |
tree | 1448cb3497d6601dad4bd642ed29a859a5c98d04 /source/blender/blenkernel | |
parent | d1d01ed5220e1b768f829319698b8842aa19bf56 (diff) |
Fix for incorrect subpixel precision of marker when using track offset
Issue was caused by the way how pattern sampling happens in case of
anchored display: track offset is applying on search buffer which
means offset is rounding to an integer. Fractional pat of offset was
completely ignoring which lead to jumps in pattern buffer.
This was only a visualization issue in track preview widget.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_tracking.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 26 |
2 files changed, 25 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 9bdc96e187d..ebf29fde8ee 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -162,7 +162,7 @@ void BKE_tracking_max_undistortion_delta_across_bound(struct MovieTracking *trac /* **** Image sampling **** */ struct ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, struct ImBuf *struct_ibuf, struct MovieTrackingTrack *track, - struct MovieTrackingMarker *marker, int use_mask, + struct MovieTrackingMarker *marker, int from_anchor, int use_mask, int num_samples_x, int num_samples_y, float pos[2]); struct ImBuf *BKE_tracking_get_pattern_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int anchored, int disable_channels); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index f63a1f2cec0..7e2970108cd 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1699,7 +1699,7 @@ static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, int g ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *search_ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, - int use_mask, int num_samples_x, int num_samples_y, + int from_anchor, int use_mask, int num_samples_x, int num_samples_y, float pos[2]) { #ifdef WITH_LIBMV @@ -1719,6 +1719,28 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea get_marker_coords_for_tracking(frame_width, frame_height, marker, src_pixel_x, src_pixel_y); + /* from_anchor means search buffer was obtained for an anchored position, + * which means applying track offset rounded to pixel space (we could not + * store search buffer with sub-pixel precision) + * + * in this case we need to alter coordinates a bit, to compensate rounded + * fractional part of offset + */ + if (from_anchor) { + int a; + + for (a = 0; a < 5; a++) { + src_pixel_x[a] += ((track->offset[0] * frame_width) - ((int) (track->offset[0] * frame_width))); + src_pixel_y[a] += ((track->offset[1] * frame_height) - ((int) (track->offset[1] * frame_height))); + + /* when offset is negative, rounding happens in opposite direction */ + if (track->offset[0] < 0.0f) + src_pixel_x[a] += 1.0f; + if (track->offset[1] < 0.0f) + src_pixel_y[a] += 1.0f; + } + } + if (use_mask) { mask = BKE_tracking_track_get_mask(frame_width, frame_height, track, marker); } @@ -1779,7 +1801,7 @@ ImBuf *BKE_tracking_get_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mo if (search_ibuf) { pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x, ibuf->y, search_ibuf, track, marker, - FALSE, num_samples_x, num_samples_y, NULL); + anchored, FALSE, num_samples_x, num_samples_y, NULL); IMB_freeImBuf(search_ibuf); } |