diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-04-06 18:47:45 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-04-06 18:47:45 +0400 |
commit | f62d2669def640f2e448e8d677af0c04b5b53439 (patch) | |
tree | 308abc2e6e4f2f1e47ef52a9c4a603cad0b630f4 | |
parent | 2ed2226ee753cc6a7a19806d99772efa61af897f (diff) |
Revert change made to bilinear sampler in libmv
This made preview working but that broke internals
of tracking.
Namely, BlurredImageAndDerivativesChannels is giving
much more blurred image because it was assuming pixel
center is an integer position.
Guess other parts of libmv used to suffer because of
this issue.
Now pixel centering happens in blender side, and
libmv assumes integer position is a pixel center.
-rw-r--r-- | extern/libmv/libmv/image/sample.h | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 16 |
2 files changed, 8 insertions, 16 deletions
diff --git a/extern/libmv/libmv/image/sample.h b/extern/libmv/libmv/image/sample.h index a95d08a9815..24eb9ccd57d 100644 --- a/extern/libmv/libmv/image/sample.h +++ b/extern/libmv/libmv/image/sample.h @@ -59,10 +59,6 @@ inline T SampleLinear(const Array3D<T> &image, float y, float x, int v = 0) { int x1, y1, x2, y2; float dx, dy; - // Take the upper left corner as integer pixel positions. - x -= 0.5; - y -= 0.5; - LinearInitAxis(y, image.Height(), &y1, &y2, &dy); LinearInitAxis(x, image.Width(), &x1, &x2, &dx); @@ -82,10 +78,6 @@ inline void SampleLinear(const Array3D<T> &image, float y, float x, T *sample) { int x1, y1, x2, y2; float dx, dy; - // Take the upper left corner as integer pixel positions. - x -= 0.5; - y -= 0.5; - LinearInitAxis(y, image.Height(), &y1, &y2, &dy); LinearInitAxis(x, image.Width(), &x1, &x2, &dx); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index fe53f073ea6..9723e65e401 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -356,8 +356,8 @@ static void get_marker_coords_for_tracking(int frame_width, int frame_height, /* Convert the corners into search space coordinates. */ for (i = 0; i < 4; i++) { marker_unified_to_search_pixel(frame_width, frame_height, marker, marker->pattern_corners[i], pixel_coords); - search_pixel_x[i] = pixel_coords[0]; - search_pixel_y[i] = pixel_coords[1]; + search_pixel_x[i] = pixel_coords[0] - 0.5; + search_pixel_y[i] = pixel_coords[1] - 0.5; } /* Convert the center position (aka "pos"); this is the origin */ @@ -365,8 +365,8 @@ static void get_marker_coords_for_tracking(int frame_width, int frame_height, unified_coords[1] = 0.0; marker_unified_to_search_pixel(frame_width, frame_height, marker, unified_coords, pixel_coords); - search_pixel_x[4] = pixel_coords[0]; - search_pixel_y[4] = pixel_coords[1]; + search_pixel_x[4] = pixel_coords[0] - 0.5; + search_pixel_y[4] = pixel_coords[1] - 0.5; } /* Inverse of above. */ @@ -379,14 +379,14 @@ static void set_marker_coords_from_tracking(int frame_width, int frame_height, M /* Convert the corners into search space coordinates. */ for (i = 0; i < 4; i++) { - search_pixel[0] = search_pixel_x[i]; - search_pixel[1] = search_pixel_y[i]; + search_pixel[0] = search_pixel_x[i] + 0.5; + search_pixel[1] = search_pixel_y[i] + 0.5; search_pixel_to_marker_unified(frame_width, frame_height, marker, search_pixel, marker->pattern_corners[i]); } /* Convert the center position (aka "pos"); this is the origin */ - search_pixel[0] = search_pixel_x[4]; - search_pixel[1] = search_pixel_y[4]; + search_pixel[0] = search_pixel_x[4] + 0.5; + search_pixel[1] = search_pixel_y[4] + 0.5; search_pixel_to_marker_unified(frame_width, frame_height, marker, search_pixel, marker_unified); /* If the tracker tracked nothing, then "marker_unified" would be zero. |