Visual Servoing Platform  version 3.6.0 under development (2023-09-29)
vpMomentCInvariant.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
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 https://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 rotations around X and
32  * Y axis.
33  */
39 #ifndef _vpMomentCInvariant_h_
40 #define _vpMomentCInvariant_h_
41 
42 #include <visp3/core/vpMoment.h>
43 #include <visp3/core/vpMomentDatabase.h>
44 
45 class vpMomentCentered;
46 class vpMomentBasic;
47 
122 class VISP_EXPORT vpMomentCInvariant : public vpMoment
123 {
124 private:
125  std::vector<double> I;
126  std::vector<double> II;
127  std::vector<double> c;
128  std::vector<double> s;
129  double K;
130  void computeI(const vpMomentCentered &momentCentered, std::vector<double> &I);
131 
132  /* To calculate Sx and Sy from normalized moments */
133  void calcSxSy(double &sx, double &sy) const;
134  void calcSxSyNormalized(double &sx, double &sy) const;
135  std::vector<double> cn; // same as s above but calculated from normalized moments
136  std::vector<double> sn; // same as c above but calculated from normalized moments
137  double In1; // same as I1 in Sx,Sy formulae but calculated from normalized
138  // moments
139  bool flg_sxsynormalization_;
140 
141 public:
142  explicit vpMomentCInvariant(bool flg_sxsynormalization = false);
143  virtual ~vpMomentCInvariant() { };
144 
148  double C1() const { return values[0]; }
152  double C2() const { return values[1]; }
156  double C3() const { return values[2]; }
160  double C4() const { return values[3]; }
164  double C5() const { return values[4]; }
168  double C6() const { return values[5]; }
172  double C7() const { return values[6]; }
176  double C8() const { return values[7]; }
180  double C9() const { return values[8]; }
184  double C10() const { return values[9]; }
185 
186  void compute();
187 
194  double get(unsigned int i) const { return values[i]; }
195 
199  double getC(unsigned int i) const { return c[i]; }
203  double getI(unsigned int index) const { return I[index]; }
204 
208  void printInvariants(std::ostream &os) const;
209 
213  double getII(unsigned int i) const { return II[i]; }
217  double getK() const { return K; }
218 
222  double getS(unsigned int i) const { return s[i]; }
223 
227  const char *name() const { return "vpMomentCInvariant"; }
228 
232  void printI(unsigned int index);
233 
237  double Px() { return values[12]; }
241  double Py() { return values[13]; }
242 
246  double Sx() const { return values[10]; }
250  double Sy() const { return values[11]; }
251 
256  double getIn1() const { return In1; }
257 
262  double getCN(unsigned int i) const { return cn[i]; }
263 
268  double getSN(unsigned int i) const { return sn[i]; }
269 
273  bool isSxSyfromNormalizedMoments() const { return flg_sxsynormalization_; };
274 
278  inline const std::vector<double> &getMomentVector() const { return values; }
279 
280  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentCInvariant &v);
281 };
282 #endif
This class defines the 2D basic moment . This class is a wrapper for vpMomentObject wich allows to us...
Definition: vpMomentBasic.h:70
const std::vector< double > & getMomentVector() const
const char * name() const
double get(unsigned int i) const
double getI(unsigned int index) const
double getS(unsigned int i) const
bool isSxSyfromNormalizedMoments() const
double getCN(unsigned int i) const
double getC(unsigned int i) const
double getSN(unsigned int i) const
double getII(unsigned int i) const
This class defines the double-indexed centered moment descriptor .
This class defines shared methods/attributes for 2D moments.
Definition: vpMoment.h:106
std::vector< double > values
Definition: vpMoment.h:113
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpMoment &m)
Definition: vpMoment.cpp:122
virtual void compute()=0