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.
This commit is contained in:
parent
d1d01ed522
commit
495aa863ae
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1602,7 +1602,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
|||
|
||||
tmpibuf = BKE_tracking_sample_pattern(scopes->frame_width, scopes->frame_height,
|
||||
scopes->track_search, scopes->track,
|
||||
&scopes->undist_marker, scopes->use_track_mask,
|
||||
&scopes->undist_marker, TRUE, scopes->use_track_mask,
|
||||
width, height, scopes->track_pos);
|
||||
|
||||
if (tmpibuf) {
|
||||
|
|
Loading…
Reference in New Issue