My Project
Public Types | Public Member Functions | List of all members
Optimization Class Reference

Non-linear optimization routines. There are three methods implemented that include Gauss-Newton, Levenberg-Marquardt and Tukey m-estimator. More...

#include <Optimization.h>

Public Types

enum  OptimizeMethod { GAUSSNEWTON , LEVENBERGMARQUARDT , TUKEY_LM }
 Selection between the algorithm used in optimization. Following should be noticed: More...
 
typedef void(* EstimateCallback) (cv::Mat &state, cv::Mat &projection, void *param)
 Pointer to the function that projects the state of the system to the measurements. More...
 

Public Member Functions

 Optimization (int n_params, int n_meas)
 Constructor. More...
 
cv::Mat GetErr ()
 Returns the current residual vector. More...
 
void CalcJacobian (cv::Mat &x, cv::Mat &J, EstimateCallback Estimate)
 Numerically differentiates and calculates the Jacobian around x. More...
 
double Optimize (cv::Mat &parameters, cv::Mat &measurements, double stop, int max_iter, EstimateCallback Estimate, void *param=0, OptimizeMethod method=LEVENBERGMARQUARDT, const cv::Mat &parameters_mask=cv::Mat(), const cv::Mat &J_mat=cv::Mat(), const cv::Mat &weights=cv::Mat())
 Runs the optimization loop with selected parameters. More...
 

Detailed Description

Non-linear optimization routines. There are three methods implemented that include Gauss-Newton, Levenberg-Marquardt and Tukey m-estimator.

Definition at line 44 of file Optimization.h.

Member Typedef Documentation

◆ EstimateCallback

typedef void(* EstimateCallback) (cv::Mat &state, cv::Mat &projection, void *param)

Pointer to the function that projects the state of the system to the measurements.

Parameters
stateSystem parameters, e.g. camera parameterization in optical tracking.
projectionThe system state projection is stored here. E.g image measurements in optical tracking.
paramAdditional parameters to the function. E.g. some constant parameters that are not optimized.

Definition at line 97 of file Optimization.h.

Member Enumeration Documentation

◆ OptimizeMethod

Selection between the algorithm used in optimization. Following should be noticed:

  • GAUSSNEWTON

Definition at line 71 of file Optimization.h.

Constructor & Destructor Documentation

◆ Optimization()

Optimization ( int  n_params,
int  n_meas 
)

Constructor.

Parameters
n_paramsNumber of parameters to be optimized.
n_measNumber of measurements that are observed.

Member Function Documentation

◆ CalcJacobian()

void CalcJacobian ( cv::Mat &  x,
cv::Mat &  J,
EstimateCallback  Estimate 
)

Numerically differentiates and calculates the Jacobian around x.

Parameters
xThe set of parameters around which the Jacobian is evaluated.
JResulting Jacobian matrix is stored here.
EstimateThe function to be differentiated.

◆ GetErr()

cv::Mat GetErr ( )
inline

Returns the current residual vector.

Returns
Pointer to the residual vector.

Definition at line 86 of file Optimization.h.

◆ Optimize()

double Optimize ( cv::Mat &  parameters,
cv::Mat &  measurements,
double  stop,
int  max_iter,
EstimateCallback  Estimate,
void *  param = 0,
OptimizeMethod  method = LEVENBERGMARQUARDT,
const cv::Mat &  parameters_mask = cv::Mat(),
const cv::Mat &  J_mat = cv::Mat(),
const cv::Mat &  weights = cv::Mat() 
)

Runs the optimization loop with selected parameters.

Parameters
parametersVector of parameters to be optimized. Initial values should be set.
measurementsVector of measurements that are observed.
stopOptimization loop ends as the stop limit is reached. Criteria is calculated as
max_iterMaximum number of iteration loops that are evaluated if stop is not reached.
EstimatePointer to the function that maps the state to the measurements. See EstimateCallback.
methodOne of the three possible optimization methods.
parameters_maskVector that defines the parameters that are optimized. If vector element is 0, corresponding parameter is not altered.
J_matJacobian matrix. If not given, numerical differentation is used.
weightsWeight vector that can be submitted to give different weights to different measurements. Currently works only with OptimizeMethod::TUKEY_LM.

The documentation for this class was generated from the following file: