18 #ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_HOMOGRAPHY_HPP 19 #define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_HOMOGRAPHY_HPP 21 #include "../util/nelder_mead_opt_base.hpp" 22 #include "../util/std_util.hpp" 24 #ifndef PIC_DISABLE_EIGEN 25 #ifndef PIC_EIGEN_NOT_BUNDLED 26 #include "../externals/Eigen/Dense" 28 #include <Eigen/Dense> 34 #ifndef PIC_DISABLE_EIGEN 39 std::vector< Eigen::Vector2f >
m0,
m1;
48 std::vector< Eigen::Vector2f > &
m1,
61 Eigen::Vector2f
Homography(Eigen::Matrix3f &H, Eigen::Vector2f &p)
63 Eigen::Vector3f ret = H * Eigen::Vector3f(p[0], p[1], 1.0f);
65 return Eigen::Vector2f(ret[0] / ret[2], ret[1] / ret[2]);
74 float function(
float *x,
unsigned int n)
81 Eigen::Matrix3f H_inv = H.inverse();
83 for(
unsigned int i = 0; i <
m0.size(); i++) {
89 dU =
m1[i][0] - p0_H[0];
90 dV =
m1[i][1] - p0_H[1];
92 err += dU * dU + dV * dV;
97 dU =
m0[i][0] - p1_H[0];
98 dV =
m0[i][1] - p1_H[1];
100 err += dU * dU + dV * dV;
115 float *
run(
float *x_start,
unsigned int n,
float epsilon = 1e-4f,
int max_iterations = 1000,
float *x = NULL)
122 x =
new float[n + 1];
136 #endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_HOMOGRAPHY_HPP float * run(float *x_start, unsigned int n, float epsilon=1e-4f, int max_iterations=1000, float *x=NULL)
run
Definition: nelder_mead_opt_homography.hpp:115
int max_iterations
Definition: nelder_mead_opt_base.hpp:295
std::vector< Eigen::Vector2f > m0
Definition: nelder_mead_opt_homography.hpp:39
std::vector< Eigen::Vector2f > m1
Definition: nelder_mead_opt_homography.hpp:39
PIC_INLINE Eigen::MatrixXf getMatrixfFromLinearArray(float *array, int rows, int cols)
getMatrixFromLinearArray
Definition: eigen_util.hpp:448
Eigen::Vector2f Homography(Eigen::Matrix3f &H, Eigen::Vector2f &p)
Homography.
Definition: nelder_mead_opt_homography.hpp:61
NelderMeadOptHomography(std::vector< Eigen::Vector2f > &m0, std::vector< Eigen::Vector2f > &m1, std::vector< unsigned int > inliers)
NelderMeadOptHomography.
Definition: nelder_mead_opt_homography.hpp:47
The NelderMeadOptBase class.
Definition: nelder_mead_opt_base.hpp:31
void filterInliers(std::vector< T > &vec, std::vector< unsigned int > &inliers, std::vector< T > &vecOut)
filterInliers
Definition: std_util.hpp:32
float * run_aux(float *x_start, unsigned int n, float epsilon, int max_iterations=1000, float *x=NULL)
run_aux
Definition: nelder_mead_opt_base.hpp:186
Definition: bilateral_separation.hpp:25
Definition: nelder_mead_opt_homography.hpp:36