For the planar tracker, initialize the warp from the four correspondences after

brute force translation search.
This commit is contained in:
Keir Mierle
2012-05-17 21:26:06 +00:00
parent d78b7fc946
commit d0ec55b8c2
2 changed files with 21 additions and 16 deletions

View File

@@ -400,8 +400,7 @@ int libmv_trackRegion(const struct libmv_trackRegionOptions *options,
if (track_region_result.termination == libmv::TrackRegionResult::PARAMETER_TOLERANCE ||
track_region_result.termination == libmv::TrackRegionResult::FUNCTION_TOLERANCE ||
track_region_result.termination == libmv::TrackRegionResult::GRADIENT_TOLERANCE ||
track_region_result.termination == libmv::TrackRegionResult::NO_CONVERGENCE ||
track_region_result.termination == libmv::TrackRegionResult::INSUFFICIENT_CORRELATION)
track_region_result.termination == libmv::TrackRegionResult::NO_CONVERGENCE)
{
tracking_result = true;
}

View File

@@ -398,7 +398,7 @@ class Quad {
struct TranslationWarp {
TranslationWarp(const double *x1, const double *y1,
const double *x2, const double *y2) {
Vec2 t = Quad(x2, y2).Centroid() - Quad(x1, y1).Centroid() ;
Vec2 t = Quad(x2, y2).Centroid() - Quad(x1, y1).Centroid();
parameters[0] = t[0];
parameters[1] = t[1];
}
@@ -908,19 +908,6 @@ void TemplatedTrackRegion(const FloatImage &image1,
}
// TODO(keir): Check quads to ensure there is some area.
// Prepare the initial warp parameters from the four correspondences.
Warp warp(x1, y1, x2, y2);
// Decide how many samples to use in the x and y dimensions.
int num_samples_x;
int num_samples_y;
PickSampling(x1, y1, x2, y2, &num_samples_x, &num_samples_y);
// Compute the warp from rectangular coordinates.
Mat3 canonical_homography = ComputeCanonicalHomography(x1, y1,
num_samples_x,
num_samples_y);
// Prepare the image and gradient.
Array3Df image_and_gradient1;
Array3Df image_and_gradient2;
@@ -938,8 +925,22 @@ void TemplatedTrackRegion(const FloatImage &image1,
image2,
options.num_extra_points,
x1, y1, x2, y2);
for (int i = 0; i < 4; ++i) {
LG << "P" << i << ": (" << x1[i] << ", " << y1[i] << "); brute ("
<< x2[i] << ", " << y2[i] << "); (dx, dy): (" << (x2[i] - x1[i]) << ", "
<< (y2[i] - y1[i]) << ").";
}
}
// Prepare the initial warp parameters from the four correspondences.
// Note: This must happen after the brute initialization runs.
Warp warp(x1, y1, x2, y2);
// Decide how many samples to use in the x and y dimensions.
int num_samples_x;
int num_samples_y;
PickSampling(x1, y1, x2, y2, &num_samples_x, &num_samples_y);
ceres::Solver::Options solver_options;
solver_options.linear_solver_type = ceres::DENSE_QR;
solver_options.max_num_iterations = options.max_iterations;
@@ -957,6 +958,11 @@ void TemplatedTrackRegion(const FloatImage &image1,
BoundaryCheckingCallback<Warp> callback(image2, warp, x1, y1);
solver_options.callbacks.push_back(&callback);
// Compute the warp from rectangular coordinates.
Mat3 canonical_homography = ComputeCanonicalHomography(x1, y1,
num_samples_x,
num_samples_y);
// Construct the warp cost function. AutoDiffCostFunction takes ownership.
WarpCostFunctor<Warp> *warp_cost_function =
new WarpCostFunctor<Warp>(options,