diff options
Diffstat (limited to 'source/blender/blenkernel/intern/tracking.c')
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 8b81e474e76..a6519f8005c 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1605,6 +1605,67 @@ ImBuf *BKE_tracking_distort_frame(MovieTracking *tracking, ImBuf *ibuf, int cali calibration_height, overscan, FALSE); } +void BKE_tracking_max_undistortion_delta_across_bound(MovieTracking *tracking, rcti *rect, float delta[2]) +{ + int a; + float pos[2], warped_pos[2]; + const int coord_delta = 5; + + delta[0] = delta[1] = -FLT_MAX; + + for (a = rect->xmin; a <= rect->xmax + coord_delta; a += coord_delta) { + if (a > rect->xmax) + a = rect->xmax; + + /* bottom edge */ + pos[0] = a; + pos[1] = rect->ymin; + + BKE_tracking_undistort_v2(tracking, pos, warped_pos); + + delta[0] = max_ff(delta[0], fabs(pos[0] - warped_pos[0])); + delta[1] = max_ff(delta[1], fabs(pos[1] - warped_pos[1])); + + /* top edge */ + pos[0] = a; + pos[1] = rect->ymax; + + BKE_tracking_undistort_v2(tracking, pos, warped_pos); + + delta[0] = max_ff(delta[0], fabs(pos[0] - warped_pos[0])); + delta[1] = max_ff(delta[1], fabs(pos[1] - warped_pos[1])); + + if (a >= rect->xmax) + break; + } + + for (a = rect->ymin; a <= rect->ymax + coord_delta; a += coord_delta) { + if (a > rect->ymax) + a = rect->ymax; + + /* left edge */ + pos[0] = rect->xmin; + pos[1] = a; + + BKE_tracking_undistort_v2(tracking, pos, warped_pos); + + delta[0] = max_ff(delta[0], fabs(pos[0] - warped_pos[0])); + delta[1] = max_ff(delta[1], fabs(pos[1] - warped_pos[1])); + + /* right edge */ + pos[0] = rect->xmax; + pos[1] = a; + + BKE_tracking_undistort_v2(tracking, pos, warped_pos); + + delta[0] = max_ff(delta[0], fabs(pos[0] - warped_pos[0])); + delta[1] = max_ff(delta[1], fabs(pos[1] - warped_pos[1])); + + if (a >= rect->ymax) + break; + } +} + /*********************** Image sampling *************************/ static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, int grayscale) |