AliceVision
Photogrammetric Computer Vision Framework
LMFunctor.hpp
1 // This file is part of the AliceVision project.
2 // Copyright (c) 2016 AliceVision contributors.
3 // Copyright (c) 2012 openMVG contributors.
4 // This Source Code Form is subject to the terms of the Mozilla Public License,
5 // v. 2.0. If a copy of the MPL was not distributed with this file,
6 // You can obtain one at https://mozilla.org/MPL/2.0/.
7 
8 #pragma once
9 
10 #include "aliceVision/numeric/numeric.hpp"
11 // Levenberg Marquardt Non Linear Optimization
12 #include <unsupported/Eigen/NonLinearOptimization>
13 #include <unsupported/Eigen/NumericalDiff>
14 
15 namespace aliceVision {
16 using namespace Eigen;
17 // Generic functor Levenberg-Marquardt minimization
18 template<typename _Scalar, int NX = Dynamic, int NY = Dynamic>
19 struct LMFunctor
20 {
21  typedef _Scalar Scalar;
22  enum
23  {
24  InputsAtCompileTime = NX,
25  ValuesAtCompileTime = NY
26  };
27  typedef Matrix<Scalar, InputsAtCompileTime, 1> InputType;
28  typedef Matrix<Scalar, ValuesAtCompileTime, 1> ValueType;
29  typedef Matrix<Scalar, ValuesAtCompileTime, InputsAtCompileTime> JacobianType;
30 
31  const int m_inputs, m_values;
32 
33  LMFunctor()
34  : m_inputs(InputsAtCompileTime),
35  m_values(ValuesAtCompileTime)
36  {}
37  LMFunctor(int inputs, int values)
38  : m_inputs(inputs),
39  m_values(values)
40  {}
41 
42  int inputs() const { return m_inputs; }
43  int values() const { return m_values; }
44 
45  // you should define that in the subclass :
46  // void operator() (const InputType& x, ValueType* v, JacobianType* _j=0) const;
47 };
48 
49 }; // namespace aliceVision
aliceVision
Definition: checkerDetector.cpp:32
aliceVision::LMFunctor
Definition: LMFunctor.hpp:19