Optimization.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
00003  *
00004  * Copyright 2007-2012 VTT Technical Research Centre of Finland
00005  *
00006  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
00007  *          <http://www.vtt.fi/multimedia/alvar.html>
00008  *
00009  * ALVAR is free software; you can redistribute it and/or modify it under the
00010  * terms of the GNU Lesser General Public License as published by the Free
00011  * Software Foundation; either version 2.1 of the License, or (at your option)
00012  * any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful, but WITHOUT
00015  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00017  * for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with ALVAR; if not, see
00021  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
00022  */
00023 
00024 #ifndef OPTIMIZATION_H
00025 #define OPTIMIZATION_H
00026 
00027 #include "Alvar.h"
00028 #include <cxcore.h>
00029 //#include <float.h>
00030 
00031 
00038 namespace alvar {
00039 
00044 class ALVAR_EXPORT Optimization 
00045 {
00046 
00047 private:
00048 
00049         void *estimate_param;
00050         CvMat *J;
00051         CvMat *JtJ;
00052         CvMat *W;
00053         CvMat *diag;
00054         CvMat *tmp;
00055         CvMat *err;
00056         CvMat *delta;
00057         CvMat *x_plus;
00058         CvMat *x_minus;
00059         CvMat *x_tmp1;
00060         CvMat *x_tmp2;
00061         CvMat *tmp_par;
00062 
00063         double CalcTukeyWeight(double residual, double c);
00064         double CalcTukeyWeightSimple(double residual, double c);
00065 
00066         double lambda;
00067 
00068 public:
00069 
00074         enum OptimizeMethod
00075         {
00076                 GAUSSNEWTON,
00077                 LEVENBERGMARQUARDT,
00078                 TUKEY_LM
00079         };
00080 
00086         Optimization(int n_params, int n_meas);
00087         ~Optimization();
00088 
00093         CvMat *GetErr() { return err; }
00094 
00101         typedef void (*EstimateCallback)(CvMat* state, CvMat *projection, void *param);
00102 
00109         void CalcJacobian(CvMat* x, CvMat* J, EstimateCallback Estimate);
00110 
00123         double Optimize(CvMat*                                  parameters,
00124                                     CvMat*                                      measurements,
00125                                         double                                  stop,
00126                                         int                                             max_iter,
00127                                         EstimateCallback                Estimate,
00128                                         void *param                             = 0,
00129                                         OptimizeMethod method   = LEVENBERGMARQUARDT,
00130                                         CvMat* parameters_mask  = 0,
00131                                         CvMat* J_mat                    = 0,
00132                                         CvMat* weights                  = 0); 
00133 
00134 };
00135 
00136 } // namespace alvar
00137 
00138 #endif


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Sat Dec 28 2013 16:46:15