Skip to content

Commit

Permalink
Fix Eigen alignment issues for Eigen 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ahojnnes committed Nov 23, 2016
1 parent 0e1d5ed commit 8e38f42
Show file tree
Hide file tree
Showing 52 changed files with 774 additions and 38 deletions.
1 change: 1 addition & 0 deletions src/base/camera_rig.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "base/camera.h"
#include "base/pose.h"
#include "base/reconstruction.h"
#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand Down
1 change: 1 addition & 0 deletions src/base/database_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "base/database.h"
#include "base/image.h"
#include "base/scene_graph.h"
#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand Down
1 change: 1 addition & 0 deletions src/base/essential_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <ceres/ceres.h>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand Down
1 change: 1 addition & 0 deletions src/base/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <Eigen/Core>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand Down
1 change: 1 addition & 0 deletions src/base/feature_matching.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "base/database.h"
#include "ext/SiftGPU/SiftGPU.h"
#include "util/alignment.h"
#include "util/cache.h"
#include "util/opengl_utils.h"
#include "util/threading.h"
Expand Down
1 change: 1 addition & 0 deletions src/base/feature_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <boost/test/unit_test.hpp>

#include "base/feature.h"
#include "util/alignment.h"

using namespace colmap;

Expand Down
1 change: 1 addition & 0 deletions src/base/gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <Eigen/Core>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand Down
1 change: 1 addition & 0 deletions src/base/homography_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <Eigen/Core>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand Down
1 change: 1 addition & 0 deletions src/base/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "base/camera.h"
#include "base/point2d.h"
#include "base/visibility_pyramid.h"
#include "util/alignment.h"
#include "util/logging.h"
#include "util/math.h"
#include "util/types.h"
Expand Down
1 change: 1 addition & 0 deletions src/base/pose.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <Eigen/Core>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand Down
2 changes: 1 addition & 1 deletion src/base/pose_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(TestAverageQuaternions) {
std::vector<Eigen::Vector4d> qvecs;
std::vector<double> weights;

qvecs = {ComposeIdentityQuaternion()};
qvecs = {{ComposeIdentityQuaternion()}};
weights = {1.0};
BOOST_CHECK_EQUAL(AverageQuaternions(qvecs, weights),
ComposeIdentityQuaternion());
Expand Down
1 change: 1 addition & 0 deletions src/base/reconstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "base/point2d.h"
#include "base/point3d.h"
#include "base/track.h"
#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand Down
1 change: 1 addition & 0 deletions src/base/similarity_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <Eigen/Core>
#include <Eigen/Geometry>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand Down
1 change: 1 addition & 0 deletions src/base/triangulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <Eigen/Core>

#include "base/camera.h"
#include "util/alignment.h"
#include "util/math.h"
#include "util/types.h"

Expand Down
1 change: 1 addition & 0 deletions src/base/undistortion.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define COLMAP_SRC_BASE_UNDISTORTION_H_

#include "base/reconstruction.h"
#include "util/alignment.h"
#include "util/bitmap.h"
#include "util/threading.h"

Expand Down
2 changes: 2 additions & 0 deletions src/base/visibility_pyramid.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <Eigen/Core>

#include "util/alignment.h"

namespace colmap {

// A class that captures the distribution of points in a 2D grid.
Expand Down
1 change: 1 addition & 0 deletions src/base/warp.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define COLMAP_SRC_BASE_WARP_H_

#include "base/camera.h"
#include "util/alignment.h"
#include "util/bitmap.h"

namespace colmap {
Expand Down
4 changes: 2 additions & 2 deletions src/estimators/epnp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ std::vector<EPnPEstimator::M_t> EPnPEstimator::Estimate(
EPnPEstimator epnp;
M_t proj_matrix;
if (!epnp.ComputePose(points2D, points3D, &proj_matrix)) {
return {};
return std::vector<EPnPEstimator::M_t>({});
}

return {proj_matrix};
return std::vector<EPnPEstimator::M_t>({proj_matrix});
}

void EPnPEstimator::Residuals(const std::vector<X_t>& points2D,
Expand Down
3 changes: 2 additions & 1 deletion src/estimators/epnp.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <Eigen/Core>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand All @@ -47,7 +48,7 @@ class EPnPEstimator {
typedef Eigen::Matrix3x4d M_t;

// The minimum number of samples needed to estimate a model.
static size_t MinNumSamples() { return 4; }
static const int kMinNumSamples = 4;

// Estimate the most probable solution of the P3P problem from a set of
// three 2D-3D point correspondences.
Expand Down
5 changes: 3 additions & 2 deletions src/estimators/essential_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <ceres/ceres.h>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand All @@ -41,7 +42,7 @@ class EssentialMatrixFivePointEstimator {
typedef Eigen::Matrix3d M_t;

// The minimum number of samples needed to estimate a model.
static size_t MinNumSamples() { return 5; }
static const int kMinNumSamples = 5;

// Estimate up to 10 possible essential matrix solutions from a set of
// corresponding points.
Expand Down Expand Up @@ -81,7 +82,7 @@ class EssentialMatrixEightPointEstimator {
typedef Eigen::Matrix3d M_t;

// The minimum number of samples needed to estimate a model.
static size_t MinNumSamples() { return 8; }
static const int kMinNumSamples = 8;

// Estimate essential matrix solutions from set of corresponding points.
//
Expand Down
1 change: 1 addition & 0 deletions src/estimators/euclidean_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define COLMAP_SRC_ESTIMATORS_EUCLIDEAN_TRANSFORM_H_

#include "base/similarity_transform.h"
#include "util/alignment.h"

namespace colmap {

Expand Down
5 changes: 3 additions & 2 deletions src/estimators/fundamental_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <Eigen/Core>

#include "estimators/homography_matrix.h"
#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand All @@ -41,7 +42,7 @@ class FundamentalMatrixSevenPointEstimator {
typedef Eigen::Matrix3d M_t;

// The minimum number of samples needed to estimate a model.
static size_t MinNumSamples() { return 7; }
static const int kMinNumSamples = 7;

// Estimate either 1 or 3 possible fundamental matrix solutions from a set of
// corresponding points.
Expand Down Expand Up @@ -81,7 +82,7 @@ class FundamentalMatrixEightPointEstimator {
typedef Eigen::Matrix3d M_t;

// The minimum number of samples needed to estimate a model.
static size_t MinNumSamples() { return 8; }
static const int kMinNumSamples = 8;

// Estimate fundamental matrix solutions from a set of corresponding points.
//
Expand Down
8 changes: 4 additions & 4 deletions src/estimators/gp3p.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ std::vector<Eigen::Vector3d> ComputeDepthsSylvester(
Eigen::VectorXd roots_real;
Eigen::VectorXd roots_imag;
if (!FindPolynomialRootsCompanionMatrix(coeffs, &roots_real, &roots_imag)) {
return {};
return std::vector<Eigen::Vector3d>();
}

// Back-substitute every lambda_3 to the system of equations.
Expand Down Expand Up @@ -198,7 +198,7 @@ std::vector<GP3PEstimator::M_t> GP3PEstimator::Estimate(
CHECK_EQ(points3D.size(), 3);

if (CheckCollinearPoints(points3D[0], points3D[1], points3D[2])) {
return {};
return std::vector<GP3PEstimator::M_t>({});
}

// Transform 2D points into compact Pluecker line representation.
Expand All @@ -209,7 +209,7 @@ std::vector<GP3PEstimator::M_t> GP3PEstimator::Estimate(

if (CheckParallelRays(plueckers[0].head<3>(), plueckers[1].head<3>(),
plueckers[2].head<3>())) {
return {};
return std::vector<GP3PEstimator::M_t>({});
}

// Compute the coefficients k1, k2, k3 using Eq. 4.
Expand All @@ -219,7 +219,7 @@ std::vector<GP3PEstimator::M_t> GP3PEstimator::Estimate(
// Compute the depths along the Pluecker lines of the observations.
const std::vector<Eigen::Vector3d> depths = ComputeDepthsSylvester(K);
if (depths.empty()) {
return {};
return std::vector<GP3PEstimator::M_t>({});
}

// For all valid depth values, compute the transformation between points in
Expand Down
13 changes: 7 additions & 6 deletions src/estimators/gp3p.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <Eigen/Core>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand All @@ -34,23 +35,23 @@ namespace colmap {
// This class is based on an original implementation by Federico Camposeco.
class GP3PEstimator {
public:
// The generalized image feature observations, which is composed of the
// relative pose of the specific camera in the generalized camera and its 2D
// image observation.
// The generalized image observations, which is composed of the relative pose
// of the specific camera in the generalized camera and its image observation.
struct X_t {
// The relative transformation from the generalized camera to the camera
// frame of the observation.
Eigen::Matrix3x4d rel_tform;
Eigen::Matrix<double, 3, 4, Eigen::DontAlign> rel_tform;
// The 2D image feature observation.
Eigen::Vector2d xy;
Eigen::Matrix<double, 2, 1, Eigen::DontAlign> xy;
};

// The observed 3D feature points in the world frame.
typedef Eigen::Vector3d Y_t;
// The transformation from the world to the generalized camera frame.
typedef Eigen::Matrix3x4d M_t;

// The minimum number of samples needed to estimate a model.
static size_t MinNumSamples() { return 3; }
static const int kMinNumSamples = 3;

// Estimate the most probable solution of the GP3P problem from a set of
// three 2D-3D point correspondences.
Expand Down
3 changes: 2 additions & 1 deletion src/estimators/homography_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <Eigen/Core>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand All @@ -35,7 +36,7 @@ class HomographyMatrixEstimator {
typedef Eigen::Matrix3d M_t;

// The minimum number of samples needed to estimate a model.
static size_t MinNumSamples() { return 4; }
static const int kMinNumSamples = 4;

// Estimate the projective transformation (homography).
//
Expand Down
2 changes: 1 addition & 1 deletion src/estimators/p3p.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ std::vector<P3PEstimator::M_t> P3PEstimator::Estimate(
Eigen::VectorXd roots_real;
Eigen::VectorXd roots_imag;
if (!FindPolynomialRootsCompanionMatrix(coeffs, &roots_real, &roots_imag)) {
return {};
return std::vector<P3PEstimator::M_t>({});
}

std::vector<M_t> models;
Expand Down
3 changes: 2 additions & 1 deletion src/estimators/p3p.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <Eigen/Core>

#include "util/alignment.h"
#include "util/types.h"

namespace colmap {
Expand All @@ -42,7 +43,7 @@ class P3PEstimator {
typedef Eigen::Matrix3x4d M_t;

// The minimum number of samples needed to estimate a model.
static size_t MinNumSamples() { return 3; }
static const int kMinNumSamples = 3;

// Estimate the most probable solution of the P3P problem from a set of
// three 2D-3D point correspondences.
Expand Down
1 change: 1 addition & 0 deletions src/estimators/pose.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "base/camera.h"
#include "base/camera_models.h"
#include "optim/loransac.h"
#include "util/alignment.h"
#include "util/logging.h"
#include "util/threading.h"
#include "util/types.h"
Expand Down
3 changes: 2 additions & 1 deletion src/estimators/similarity_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <Eigen/Geometry>

#include "base/projection.h"
#include "util/alignment.h"
#include "util/logging.h"
#include "util/types.h"

Expand All @@ -49,7 +50,7 @@ class SimilarityTransformEstimator {
// The minimum number of samples needed to estimate a model. Note that
// this only returns the true minimal sample in the two-dimensional case.
// For higher dimensions, the system will alway be over-determined.
static size_t MinNumSamples() { return kDim; }
static const int kMinNumSamples = kDim;

// Estimate the similarity transform.
//
Expand Down
3 changes: 2 additions & 1 deletion src/estimators/translation_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <Eigen/Core>
#include <Eigen/Geometry>

#include "util/alignment.h"
#include "util/logging.h"
#include "util/types.h"

Expand All @@ -36,7 +37,7 @@ class TranslationTransformEstimator {
typedef Eigen::Matrix<double, kDim, 1> M_t;

// The minimum number of samples needed to estimate a model.
static size_t MinNumSamples() { return 1; }
static const int kMinNumSamples = 1;

// Estimate the 2D translation transform.
//
Expand Down
Loading

0 comments on commit 8e38f42

Please sign in to comment.