Visual Servoing Platform  version 3.6.1 under development (2024-12-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 
50 BEGIN_VISP_NAMESPACE
51 class vpMomentObject;
52 class vpMomentDatabase;
54 class vpMoment;
55 
161 class VISP_EXPORT vpFeatureMoment : public vpBasicFeature
162 {
163 protected:
164  const vpMoment *moment;
165  const vpMoment &getMoment() const { return *moment; }
168  std::vector<vpMatrix> interaction_matrices;
169 
170  double A;
171  double B;
172  double C;
173  std::string m_name;
174 
175  // private:
176  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
177  // vpFeatureMoment(const vpFeatureMoment &fm)
178  // : vpBasicFeature(), moment(nullptr), moments(fm.moments),
179  // featureMomentsDataBase(nullptr),
180  // interaction_matrices(), A(0), B(0), C(0)
181  // {
182  // throw vpException(vpException::functionNotImplementedError, "Not
183  // implemented!");
184  // }
185  // vpFeatureMoment &operator=(const vpFeatureMoment &){
186  // throw vpException(vpException::functionNotImplementedError, "Not
187  // implemented!"); return *this;
188  // }
189  //#endif
190 
191 public:
206  vpFeatureMoment(vpMomentDatabase &data_base, double A_ = 0.0, double B_ = 0.0, double C_ = 0.0,
207  vpFeatureMomentDatabase *featureMoments = nullptr, unsigned int nbmatrices = 1)
208  : vpBasicFeature(), moment(nullptr), moments(data_base), featureMomentsDataBase(featureMoments),
209  interaction_matrices(nbmatrices), A(A_), B(B_), C(C_), m_name()
210  { }
211 
214  virtual void compute_interaction(void);
215 
216  vpBasicFeature *duplicate() const VP_OVERRIDE;
217  void display(const vpCameraParameters &cam, const vpImage<unsigned char> &I, const vpColor &color = vpColor::green,
218  unsigned int thickness = 1) const VP_OVERRIDE;
219  void display(const vpCameraParameters &cam, const vpImage<vpRGBa> &I, const vpColor &color = vpColor::green,
220  unsigned int thickness = 1) const VP_OVERRIDE;
221 
222  int getDimension(unsigned int select = FEATURE_ALL) const;
223  void init(void) VP_OVERRIDE;
224  vpMatrix interaction(unsigned int select = FEATURE_ALL) VP_OVERRIDE;
225 
226  void linkTo(vpFeatureMomentDatabase &featureMoments);
227 
232  virtual const std::string momentName() const = 0;
233 
237  virtual const std::string name() const = 0;
238 
239  void print(unsigned int select = FEATURE_ALL) const VP_OVERRIDE;
240  virtual void printDependencies(std::ostream &os) const;
241 
242  void update(double A, double B, double C);
243 
245  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMoment &featM);
246 };
247 
265 class VISP_EXPORT vpMomentGenericFeature : public vpFeatureMoment
266 {
267 public:
268  vpMomentGenericFeature(vpMomentDatabase &data_base, double A_, double B_, double C_,
269  vpFeatureMomentDatabase *featureMoments, const vpMoment *p_moment)
270  : vpFeatureMoment(data_base, A_, B_, C_, featureMoments)
271  {
272  this->moment = p_moment;
273  }
274 
278  const std::string momentName() const { return std::string(); }
279 
283  virtual const std::string name() const { return std::string(); }
284 };
285 END_VISP_NAMESPACE
286 #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:157
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:131
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:169
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:65