Visual Servoing Platform  version 3.6.1 under development (2024-04-27)
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 
50 class vpMomentObject;
51 class vpMomentDatabase;
53 class vpMoment;
54 
156 class VISP_EXPORT vpFeatureMoment : public vpBasicFeature
157 {
158 protected:
159  const vpMoment *moment;
160  const vpMoment &getMoment() const { return *moment; }
163  std::vector<vpMatrix> interaction_matrices;
164 
165  double A;
166  double B;
167  double C;
168  std::string m_name;
169 
170  // private:
171  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
172  // vpFeatureMoment(const vpFeatureMoment &fm)
173  // : vpBasicFeature(), moment(nullptr), moments(fm.moments),
174  // featureMomentsDataBase(nullptr),
175  // interaction_matrices(), A(0), B(0), C(0)
176  // {
177  // throw vpException(vpException::functionNotImplementedError, "Not
178  // implemented!");
179  // }
180  // vpFeatureMoment &operator=(const vpFeatureMoment &){
181  // throw vpException(vpException::functionNotImplementedError, "Not
182  // implemented!"); return *this;
183  // }
184  //#endif
185 
186 public:
201  vpFeatureMoment(vpMomentDatabase &data_base, double A_ = 0.0, double B_ = 0.0, double C_ = 0.0,
202  vpFeatureMomentDatabase *featureMoments = nullptr, unsigned int nbmatrices = 1)
203  : vpBasicFeature(), moment(nullptr), moments(data_base), featureMomentsDataBase(featureMoments),
204  interaction_matrices(nbmatrices), A(A_), B(B_), C(C_), m_name()
205  { }
206 
209  virtual void compute_interaction(void);
210 
211  vpBasicFeature *duplicate() const vp_override;
212  void display(const vpCameraParameters &cam, const vpImage<unsigned char> &I, const vpColor &color = vpColor::green,
213  unsigned int thickness = 1) const vp_override;
214  void display(const vpCameraParameters &cam, const vpImage<vpRGBa> &I, const vpColor &color = vpColor::green,
215  unsigned int thickness = 1) const vp_override;
216 
217  int getDimension(unsigned int select = FEATURE_ALL) const;
218  void init(void) vp_override;
219  vpMatrix interaction(unsigned int select = FEATURE_ALL) vp_override;
220 
221  void linkTo(vpFeatureMomentDatabase &featureMoments);
222 
227  virtual const std::string momentName() const = 0;
228 
232  virtual const std::string name() const = 0;
233 
234  void print(unsigned int select = FEATURE_ALL) const vp_override;
235  virtual void printDependencies(std::ostream &os) const;
236 
237  void update(double A, double B, double C);
238 
240  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMoment &featM);
241 };
242 
260 class VISP_EXPORT vpMomentGenericFeature : public vpFeatureMoment
261 {
262 public:
263  vpMomentGenericFeature(vpMomentDatabase &data_base, double A_, double B_, double C_,
264  vpFeatureMomentDatabase *featureMoments, const vpMoment *p_moment)
265  : vpFeatureMoment(data_base, A_, B_, C_, featureMoments)
266  {
267  this->moment = p_moment;
268  }
269 
273  const std::string momentName() const { return std::string(); }
274 
278  virtual const std::string name() const { return std::string(); }
279 };
280 
281 #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:152
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:69
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
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:105
Definition: vpRGBa.h:61