Visual Servoing Platform  version 3.6.1 under development (2024-06-12)
vpFeatureMoment.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  * Base for all moment features
32  */
33 
41 #ifndef _vpFeatureMoment_h_
42 #define _vpFeatureMoment_h_
43 
44 #include <vector>
45 #include <string>
46 #include <visp3/core/vpConfig.h>
47 #include <visp3/core/vpException.h>
48 #include <visp3/visual_features/vpBasicFeature.h>
49 
51 class vpMomentObject;
52 class vpMomentDatabase;
54 class vpMoment;
55 
157 class VISP_EXPORT vpFeatureMoment : public vpBasicFeature
158 {
159 protected:
160  const vpMoment *moment;
161  const vpMoment &getMoment() const { return *moment; }
164  std::vector<vpMatrix> interaction_matrices;
165 
166  double A;
167  double B;
168  double C;
169  std::string m_name;
170 
171  // private:
172  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
173  // vpFeatureMoment(const vpFeatureMoment &fm)
174  // : vpBasicFeature(), moment(nullptr), moments(fm.moments),
175  // featureMomentsDataBase(nullptr),
176  // interaction_matrices(), A(0), B(0), C(0)
177  // {
178  // throw vpException(vpException::functionNotImplementedError, "Not
179  // implemented!");
180  // }
181  // vpFeatureMoment &operator=(const vpFeatureMoment &){
182  // throw vpException(vpException::functionNotImplementedError, "Not
183  // implemented!"); return *this;
184  // }
185  //#endif
186 
187 public:
202  vpFeatureMoment(vpMomentDatabase &data_base, double A_ = 0.0, double B_ = 0.0, double C_ = 0.0,
203  vpFeatureMomentDatabase *featureMoments = nullptr, unsigned int nbmatrices = 1)
204  : vpBasicFeature(), moment(nullptr), moments(data_base), featureMomentsDataBase(featureMoments),
205  interaction_matrices(nbmatrices), A(A_), B(B_), C(C_), m_name()
206  { }
207 
210  virtual void compute_interaction(void);
211 
212  vpBasicFeature *duplicate() const vp_override;
213  void display(const vpCameraParameters &cam, const vpImage<unsigned char> &I, const vpColor &color = vpColor::green,
214  unsigned int thickness = 1) const vp_override;
215  void display(const vpCameraParameters &cam, const vpImage<vpRGBa> &I, const vpColor &color = vpColor::green,
216  unsigned int thickness = 1) const vp_override;
217 
218  int getDimension(unsigned int select = FEATURE_ALL) const;
219  void init(void) vp_override;
220  vpMatrix interaction(unsigned int select = FEATURE_ALL) vp_override;
221 
222  void linkTo(vpFeatureMomentDatabase &featureMoments);
223 
228  virtual const std::string momentName() const = 0;
229 
233  virtual const std::string name() const = 0;
234 
235  void print(unsigned int select = FEATURE_ALL) const vp_override;
236  virtual void printDependencies(std::ostream &os) const;
237 
238  void update(double A, double B, double C);
239 
241  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMoment &featM);
242 };
243 
261 class VISP_EXPORT vpMomentGenericFeature : public vpFeatureMoment
262 {
263 public:
264  vpMomentGenericFeature(vpMomentDatabase &data_base, double A_, double B_, double C_,
265  vpFeatureMomentDatabase *featureMoments, const vpMoment *p_moment)
266  : vpFeatureMoment(data_base, A_, B_, C_, featureMoments)
267  {
268  this->moment = p_moment;
269  }
270 
274  const std::string momentName() const { return std::string(); }
275 
279  virtual const std::string name() const { return std::string(); }
280 };
282 #endif
class that defines what is a visual feature
virtual vpBasicFeature * duplicate() const =0
Generic class defining intrinsic camera parameters.
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:153
This class allows to register all feature moments (implemented in vpFeatureMoment....
This class defines shared system methods/attributes for 2D moment features but no functional code....
std::string m_name
vpFeatureMoment(vpMomentDatabase &data_base, double A_=0.0, double B_=0.0, double C_=0.0, vpFeatureMomentDatabase *featureMoments=nullptr, unsigned int nbmatrices=1)
std::vector< vpMatrix > interaction_matrices
vpFeatureMomentDatabase * featureMomentsDataBase
vpMomentDatabase & moments
const vpMoment & getMoment() const
const vpMoment * moment
Definition of the vpImage class member functions.
Definition: vpImage.h:136
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:151
This class allows to register all vpMoments so they can access each other according to their dependen...
This class defines a generic feature used for moment feature duplication.
vpMomentGenericFeature(vpMomentDatabase &data_base, double A_, double B_, double C_, vpFeatureMomentDatabase *featureMoments, const vpMoment *p_moment)
const std::string momentName() const
virtual const std::string name() const
Class for generic objects.
This class defines shared methods/attributes for 2D moments.
Definition: vpMoment.h:106
Definition: vpRGBa.h:63