PICCANTE  0.4
The hottest HDR imaging library!
nelder_mead_opt_ICP_2D.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_ICP_2D_HPP
19 #define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_ICP_2D_HPP
20 
21 #include "../util/eigen_util.hpp"
22 #include "../util/std_util.hpp"
23 #include "../util/matrix_3_x_3.hpp"
24 #include "../util/nelder_mead_opt_base.hpp"
25 
26 #include "../computer_vision/iterative_closest_point_2D.hpp"
27 
28 #ifndef PIC_DISABLE_EIGEN
29 #ifndef PIC_EIGEN_NOT_BUNDLED
30  #include "../externals/Eigen/Dense"
31 #else
32  #include <Eigen/Dense>
33 #endif
34 #endif
35 
36 namespace pic {
37 
38 #ifndef PIC_DISABLE_EIGEN
39 
41 {
42 public:
43  std::vector< Eigen::Vector2f > points_pattern, points;
44 
50  NelderMeadOptICP2D(std::vector< Eigen::Vector2f > &points_pattern,
51  std::vector< Eigen::Vector2f > &points) : NelderMeadOptBase()
52  {
53  std::copy(points_pattern.begin(), points_pattern.end(),
54  std::back_inserter(this->points_pattern));
55 
56  std::copy(points.begin(), points.end(),
57  std::back_inserter(this->points));
58  }
59 
66  float function(float *x, unsigned int n)
67  {
68  float scale = 1.0f;
69  if(n == 4) {
70  if(x[3] < 1.0f) {
71  return FLT_MAX;
72  }
73 
74  scale = x[3];
75  }
76 
77  ICP2DTransform t(x[0], x[1], x[2], scale);
78 
79  std::vector< Eigen::Vector2f > out;
80  t.applyC(points_pattern, out);
81 
82  return getErrorPointsList(out, points);
83  }
84 };
85 #endif
86 
87 }
88 
89 #endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_ICP_2D_HPP
PIC_INLINE float getErrorPointsList(std::vector< Eigen::Vector2f > &p0, std::vector< Eigen::Vector2f > &p1)
getErrorPointsList
Definition: iterative_closest_point_2D.hpp:307
void applyC(std::vector< Eigen::Vector2f > &points)
Definition: iterative_closest_point_2D.hpp:158
std::vector< Eigen::Vector2f > points_pattern
Definition: nelder_mead_opt_ICP_2D.hpp:43
Definition: nelder_mead_opt_ICP_2D.hpp:40
NelderMeadOptICP2D(std::vector< Eigen::Vector2f > &points_pattern, std::vector< Eigen::Vector2f > &points)
NelderMeadOptICP2D.
Definition: nelder_mead_opt_ICP_2D.hpp:50
The NelderMeadOptBase class.
Definition: nelder_mead_opt_base.hpp:31
std::vector< Eigen::Vector2f > points
Definition: nelder_mead_opt_ICP_2D.hpp:43
Definition: bilateral_separation.hpp:25
Definition: iterative_closest_point_2D.hpp:97