Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMomentCInvariant.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 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  virtual ~vpMomentCInvariant() {};
135 
139  double C1() const { return values[0]; }
143  double C2() const { return values[1]; }
147  double C3() const { return values[2]; }
151  double C4() const { return values[3]; }
155  double C5() const { return values[4]; }
159  double C6() const { return values[5]; }
163  double C7() const { return values[6]; }
167  double C8() const { return values[7]; }
171  double C9() const { return values[8]; }
175  double C10() const { return values[9]; }
176 
177  void compute();
178 
183  double get(unsigned int i) const { return values[i]; }
184 
188  double getC(unsigned int i) const {return c[i];}
192  double getI(unsigned int index) const {return I[index];}
193 
197  void printInvariants(std::ostream& os) const;
198 
202  double getII(unsigned int i) const {return II[i];}
206  double getK() const {return K;}
207 
211  double getS(unsigned int i) const {return s[i];}
212 
216  const char* name() const {return "vpMomentCInvariant";}
217 
221  void printI(unsigned int index);
222 
226  double Px(){ return values[12]; }
230  double Py(){ return values[13]; }
231 
235  double Sx() const { return values[10]; }
239  double Sy() const { return values[11]; }
240 
245  double getIn1() const {return In1;}
246 
251  double getCN(unsigned int i) const {return cn[i];}
252 
257  double getSN(unsigned int i) const {return sn[i];}
258 
262  bool isSxSyfromNormalizedMoments() const {return flg_sxsynormalization_;};
263 
267  inline const std::vector<double>& getMomentVector() const { return values; }
268 
269  friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentCInvariant& v);
270 };
271 #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