ViSP  2.10.0
vpMomentCInvariant.h
1 /****************************************************************************
2  *
3  * $Id: vpMomentCInvariant.h 5303 2015-02-10 17:01:28Z mbakthav $
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  void printInvariants(std::ostream& os) const;
201 
205  double getII(unsigned int i) const {return II[i];}
209  double getK() const {return K;}
210 
214  double getS(unsigned int i) const {return s[i];}
215 
219  const char* name() const {return "vpMomentCInvariant";}
220 
224  void printI(unsigned int index);
225 
229  double Px(){ return values[12]; }
233  double Py(){ return values[13]; }
234 
238  double Sx() const { return values[10]; }
242  double Sy() const { return values[11]; }
243 
248  double getIn1() const {return In1;}
249 
254  double getCN(unsigned int i) const {return cn[i];}
255 
260  double getSN(unsigned int i) const {return sn[i];}
261 
265  bool isSxSyfromNormalizedMoments() const {return flg_sxsynormalization_;};
266 
270  inline const std::vector<double>& getMomentVector() const { return values; }
271 
272  friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentCInvariant& v);
273 };
274 #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