Visual Servoing Platform  version 3.0.0
vpMomentCInvariant.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Descriptor for various invariants used to drive space roations around X and Y axis.
32  *
33  * Authors:
34  * Filip Novotny
35  *
36  *****************************************************************************/
41 #ifndef __MOMENTCINVARIANT_H__
42 #define __MOMENTCINVARIANT_H__
43 
44 #include <visp3/core/vpMoment.h>
45 #include <visp3/core/vpMomentDatabase.h>
46 
47 class vpMomentCentered;
48 class vpMomentBasic;
49 
114 class VISP_EXPORT vpMomentCInvariant : public vpMoment {
115  private:
116  std::vector<double> I;
117  std::vector<double> II;
118  std::vector<double> c;
119  std::vector<double> s;
120  double K;
121  void computeI(const vpMomentCentered& momentCentered, std::vector<double>& I);
122 
123  /* To calculate Sx and Sy from normalized moments */
124  void calcSxSy(double& sx, double& sy) const;
125  void calcSxSyNormalized(double& sx, double& sy) const;
126  std::vector<double> cn; // same as s above but calculated from normalized moments
127  std::vector<double> sn; // same as c above but calculated from normalized moments
128  double In1; // same as I1 in Sx,Sy formulae but calculated from normalized moments
129  bool flg_sxsynormalization_;
130 
131  public:
132 
133  vpMomentCInvariant(bool flg_sxsynormalization = false);
134 
138  double C1() const { return values[0]; }
142  double C2() const { return values[1]; }
146  double C3() const { return values[2]; }
150  double C4() const { return values[3]; }
154  double C5() const { return values[4]; }
158  double C6() const { return values[5]; }
162  double C7() const { return values[6]; }
166  double C8() const { return values[7]; }
170  double C9() const { return values[8]; }
174  double C10() const { return values[9]; }
175 
176  void compute();
177 
182  double get(unsigned int i) const { return values[i]; }
183 
187  double getC(unsigned int i) const {return c[i];}
191  double getI(unsigned int index) const {return I[index];}
192 
196  void printInvariants(std::ostream& os) const;
197 
201  double getII(unsigned int i) const {return II[i];}
205  double getK() const {return K;}
206 
210  double getS(unsigned int i) const {return s[i];}
211 
215  const char* name() const {return "vpMomentCInvariant";}
216 
220  void printI(unsigned int index);
221 
225  double Px(){ return values[12]; }
229  double Py(){ return values[13]; }
230 
234  double Sx() const { return values[10]; }
238  double Sy() const { return values[11]; }
239 
244  double getIn1() const {return In1;}
245 
250  double getCN(unsigned int i) const {return cn[i];}
251 
256  double getSN(unsigned int i) const {return sn[i];}
257 
261  bool isSxSyfromNormalizedMoments() const {return flg_sxsynormalization_;};
262 
266  inline const std::vector<double>& getMomentVector() const { return values; }
267 
268  friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentCInvariant& v);
269 };
270 #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:70
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:106
This class defines the double-indexed centered moment descriptor .
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpMoment &m)
Definition: vpMoment.cpp:125
double getII(unsigned int i) const
double getCN(unsigned int i) const
std::vector< double > values
Definition: vpMoment.h:114
virtual void compute()=0