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
Notes: blender-bot 2023-02-14 09:20:15 +01:00
Referenced by issue #44110, Plane Track Issue since 2.74
1 changed files with 15 additions and 10 deletions

View File

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