Fix T44110: Plane track doesn't work when built with scons

For some reason recent change in avoiding non-aligned eigen vectors
was behaving differently for cmake and scons. Made it a bit different
now by storing scalars. This is more robust approach anyway, because
it's not really guaranteed Mat.col() gives a pointer inside data,
depending on column-major vs. row-major storage.

This is to be backported to 2.74 branch.
This commit is contained in:
Sergey Sharybin 2015-03-24 14:03:14 +05:00
parent cf365275c2
commit 0f0e080a26

@ -179,8 +179,12 @@ void GetNormalizedPoints(const Mat &original_points,
class HomographySymmetricGeometricCostFunctor { class HomographySymmetricGeometricCostFunctor {
public: public:
HomographySymmetricGeometricCostFunctor(const Vec2 &x, HomographySymmetricGeometricCostFunctor(const Vec2 &x,
const Vec2 &y) const Vec2 &y) {
: x_(x), y_(y) { } xx_ = x(0);
xy_ = x(1);
yx_ = y(0);
yy_ = y(1);
}
template<typename T> template<typename T>
bool operator()(const T *homography_parameters, T *residuals) const { bool operator()(const T *homography_parameters, T *residuals) const {
@ -189,8 +193,8 @@ class HomographySymmetricGeometricCostFunctor {
Mat3 H(homography_parameters); Mat3 H(homography_parameters);
Vec3 x(T(x_(0)), T(x_(1)), T(1.0)); Vec3 x(T(xx_), T(xy_), T(1.0));
Vec3 y(T(y_(0)), T(y_(1)), T(1.0)); Vec3 y(T(yx_), T(yy_), T(1.0));
Vec3 H_x = H * x; Vec3 H_x = H * x;
Vec3 Hinv_y = H.inverse() * y; Vec3 Hinv_y = H.inverse() * y;
@ -199,18 +203,19 @@ class HomographySymmetricGeometricCostFunctor {
Hinv_y /= Hinv_y(2); Hinv_y /= Hinv_y(2);
// This is a forward error. // This is a forward error.
residuals[0] = H_x(0) - T(y_(0)); residuals[0] = H_x(0) - T(yx_);
residuals[1] = H_x(1) - T(y_(1)); residuals[1] = H_x(1) - T(yy_);
// This is a backward error. // This is a backward error.
residuals[2] = Hinv_y(0) - T(x_(0)); residuals[2] = Hinv_y(0) - T(xx_);
residuals[3] = Hinv_y(1) - T(x_(1)); residuals[3] = Hinv_y(1) - T(xy_);
return true; return true;
} }
const Vec2 &x_; // TODO(sergey): Think of better naming.
const Vec2 &y_; double xx_, xy_;
double yx_, yy_;
}; };
// Termination checking callback used for homography estimation. // Termination checking callback used for homography estimation.