PICCANTE  0.4
The hottest HDR imaging library!
nelder_mead_opt_triangulation.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_TRIANGULATION_HPP
19 #define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_TRIANGULATION_HPP
20 
21 #include "../util/matrix_3_x_3.hpp"
22 #include "../util/nelder_mead_opt_base.hpp"
23 
24 #ifndef PIC_DISABLE_EIGEN
25 #ifndef PIC_EIGEN_NOT_BUNDLED
26  #include "../externals/Eigen/Dense"
27 #else
28  #include <Eigen/Dense>
29 #endif
30 #endif
31 
32 namespace pic {
33 
34 #ifndef PIC_DISABLE_EIGEN
35 
37 {
38 public:
39 
40  std::vector< Eigen::Matrix34d > M;
41  std::vector< Eigen::Vector2f > p;
42 
48  NelderMeadOptTriangulation(Eigen::Matrix34d &M0, Eigen::Matrix34d &M1) : NelderMeadOptBase()
49  {
50  this->M.push_back(M0);
51  this->M.push_back(M1);
52  }
53 
59  NelderMeadOptTriangulation(std::vector< Eigen::Matrix34d> &M) : NelderMeadOptBase()
60  {
61  this->M.assign(M.begin(), M.end());
62  }
63 
69  void update(Eigen::Vector2f &p0, Eigen::Vector2f &p1)
70  {
71  this->p.clear();
72  this->p.push_back(p0);
73  this->p.push_back(p1);
74  }
75 
81  void update(std::vector< Eigen::Vector2f> &p)
82  {
83  this->p.clear();
84  this->p.assign(p.begin(), p.end());
85  }
86 
93  double function(double *x, unsigned int n)
94  {
95  Eigen::Vector4d point(x[0], x[1], x[2], 1.0);
96 
97  double err = 0.0;
98  for(unsigned int i = 0; i < M.size(); i++) {
99  Eigen::Vector3d proj = M[i] * point;
100 
101  proj[0] /= proj[2];
102  proj[1] /= proj[2];
103 
104  double dx = p[i][0] - proj[0];
105  double dy = p[i][1] - proj[1];
106 
107  err += (dx * dx) + (dy * dy);
108  }
109 
110  return err;
111  }
112 };
113 
114 #endif
115 
116 }
117 
118 #endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_TRIANGULATION_HPP
void update(std::vector< Eigen::Vector2f > &p)
update
Definition: nelder_mead_opt_triangulation.hpp:81
NelderMeadOptTriangulation(std::vector< Eigen::Matrix34d > &M)
NelderMeadOptTriangulation.
Definition: nelder_mead_opt_triangulation.hpp:59
NelderMeadOptTriangulation(Eigen::Matrix34d &M0, Eigen::Matrix34d &M1)
NelderMeadOptTriangulation.
Definition: nelder_mead_opt_triangulation.hpp:48
The NelderMeadOptBase class.
Definition: nelder_mead_opt_base.hpp:31
void update(Eigen::Vector2f &p0, Eigen::Vector2f &p1)
update
Definition: nelder_mead_opt_triangulation.hpp:69
Definition: bilateral_separation.hpp:25
std::vector< Eigen::Matrix34d > M
Definition: nelder_mead_opt_triangulation.hpp:40
Definition: nelder_mead_opt_triangulation.hpp:36
std::vector< Eigen::Vector2f > p
Definition: nelder_mead_opt_triangulation.hpp:41