Visual Servoing Platform  version 3.5.1 under development (2023-03-29)
vpMomentCInvariant.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Descriptor for various invariants used to drive space roations around X and
33  *Y axis.
34  *
35  * Authors:
36  * Filip Novotny
37  *
38  *****************************************************************************/
44 #ifndef _vpMomentCInvariant_h_
45 #define _vpMomentCInvariant_h_
46 
47 #include <visp3/core/vpMoment.h>
48 #include <visp3/core/vpMomentDatabase.h>
49 
50 class vpMomentCentered;
51 class vpMomentBasic;
52 
127 class VISP_EXPORT vpMomentCInvariant : public vpMoment
128 {
129 private:
130  std::vector<double> I;
131  std::vector<double> II;
132  std::vector<double> c;
133  std::vector<double> s;
134  double K;
135  void computeI(const vpMomentCentered &momentCentered, std::vector<double> &I);
136 
137  /* To calculate Sx and Sy from normalized moments */
138  void calcSxSy(double &sx, double &sy) const;
139  void calcSxSyNormalized(double &sx, double &sy) const;
140  std::vector<double> cn; // same as s above but calculated from normalized moments
141  std::vector<double> sn; // same as c above but calculated from normalized moments
142  double In1; // same as I1 in Sx,Sy formulae but calculated from normalized
143  // moments
144  bool flg_sxsynormalization_;
145 
146 public:
147  explicit vpMomentCInvariant(bool flg_sxsynormalization = false);
148  virtual ~vpMomentCInvariant(){};
149 
153  double C1() const { return values[0]; }
157  double C2() const { return values[1]; }
161  double C3() const { return values[2]; }
165  double C4() const { return values[3]; }
169  double C5() const { return values[4]; }
173  double C6() const { return values[5]; }
177  double C7() const { return values[6]; }
181  double C8() const { return values[7]; }
185  double C9() const { return values[8]; }
189  double C10() const { return values[9]; }
190 
191  void compute();
192 
199  double get(unsigned int i) const { return values[i]; }
200 
204  double getC(unsigned int i) const { return c[i]; }
208  double getI(unsigned int index) const { return I[index]; }
209 
213  void printInvariants(std::ostream &os) const;
214 
218  double getII(unsigned int i) const { return II[i]; }
222  double getK() const { return K; }
223 
227  double getS(unsigned int i) const { return s[i]; }
228 
232  const char *name() const { return "vpMomentCInvariant"; }
233 
237  void printI(unsigned int index);
238 
242  double Px() { return values[12]; }
246  double Py() { return values[13]; }
247 
251  double Sx() const { return values[10]; }
255  double Sy() const { return values[11]; }
256 
261  double getIn1() const { return In1; }
262 
267  double getCN(unsigned int i) const { return cn[i]; }
268 
273  double getSN(unsigned int i) const { return sn[i]; }
274 
278  bool isSxSyfromNormalizedMoments() const { return flg_sxsynormalization_; };
279 
283  inline const std::vector<double> &getMomentVector() const { return values; }
284 
285  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentCInvariant &v);
286 };
287 #endif
This class defines the 2D basic moment . This class is a wrapper for vpMomentObject wich allows to us...
Definition: vpMomentBasic.h:75
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:111
std::vector< double > values
Definition: vpMoment.h:118
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpMoment &m)
Definition: vpMoment.cpp:122
virtual void compute()=0