ViSP  2.9.0
vpMomentCInvariant.h
1 /****************************************************************************
2  *
3  * $Id: vpMomentCInvariant.h 4574 2014-01-09 08:48:51Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Descriptor for various invariants used to drive space roations around X and Y axis.
36  *
37  * Authors:
38  * Filip Novotny
39  *
40  *****************************************************************************/
45 #ifndef __MOMENTCINVARIANT_H__
46 #define __MOMENTCINVARIANT_H__
47 
48 #include <visp/vpMoment.h>
49 #include <visp/vpMomentDatabase.h>
50 
51 class vpMomentCentered;
52 class vpMomentBasic;
53 
118 class VISP_EXPORT vpMomentCInvariant : public vpMoment {
119  private:
120  std::vector<double> I;
121  std::vector<double> II;
122  std::vector<double> c;
123  std::vector<double> s;
124  double K;
125  void computeI(const vpMomentCentered& momentCentered, std::vector<double>& I);
126 
127  /* To calculate Sx and Sy from normalized moments */
128  void calcSxSy(double& sx, double& sy) const;
129  void calcSxSyNormalized(double& sx, double& sy) const;
130  std::vector<double> cn; // same as s above but calculated from normalized moments
131  std::vector<double> sn; // same as c above but calculated from normalized moments
132  double In1; // same as I1 in Sx,Sy formulae but calculated from normalized moments
133  bool flg_sxsynormalization_;
134 
135  public:
136 
137  vpMomentCInvariant(bool flg_sxsynormalization = false);
138 
142  double C1() const { return values[0]; }
146  double C2() const { return values[1]; }
150  double C3() const { return values[2]; }
154  double C4() const { return values[3]; }
158  double C5() const { return values[4]; }
162  double C6() const { return values[5]; }
166  double C7() const { return values[6]; }
170  double C8() const { return values[7]; }
174  double C9() const { return values[8]; }
178  double C10() const { return values[9]; }
179 
180  void compute();
181 
186  double get(unsigned int i) const { return values[i]; }
187 
191  double getC(unsigned int i) const {return c[i];}
195  double getI(unsigned int index) const {return I[index];}
196 
200  double getII(unsigned int i) const {return II[i];}
204  double getK() const {return K;}
205 
209  double getS(unsigned int i) const {return s[i];}
210 
214  const char* name() const {return "vpMomentCInvariant";}
215 
219  void printI(unsigned int index);
220 
224  double Px(){ return values[12]; }
228  double Py(){ return values[13]; }
229 
233  double Sx() const { return values[10]; }
237  double Sy() const { return values[11]; }
238 
243  double getIn1() const {return In1;}
244 
249  double getCN(unsigned int i) const {return cn[i];}
250 
255  double getSN(unsigned int i) const {return sn[i];}
256 
260  bool isSxSyfromNormalizedMoments() const {return flg_sxsynormalization_;};
261 
265  inline const std::vector<double>& getMomentVector() const { return values; }
266 
267  friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentCInvariant& v);
268 };
269 #endif
double getS(unsigned int i) const
bool isSxSyfromNormalizedMoments() const
This class defines the 2D basic moment . This class is a wrapper for vpMomentObject wich allows to us...
Definition: vpMomentBasic.h:74
double getSN(unsigned int i) const
double getK() const
const std::vector< double > & getMomentVector() const
const char * name() const
double getI(unsigned int index) const
double getIn1() const
double getC(unsigned int i) const
This class defines shared methods/attributes for 2D moments.
Definition: vpMoment.h:108
This class defines the double-indexed centered moment descriptor .
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpMoment &m)
Definition: vpMoment.cpp:129
double getII(unsigned int i) const
double getCN(unsigned int i) const
std::vector< double > values
Definition: vpMoment.h:114
virtual void compute()=0