Visual Servoing Platform  version 3.2.1 under development (2019-05-26)
vpFeatureMoment.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  * Base for all moment features
33  *
34  * Authors:
35  * Filip Novotny
36  *
37  *****************************************************************************/
45 #ifndef _vpFeatureMoment_h_
46 #define _vpFeatureMoment_h_
47 
48 #include <vector>
49 #include <visp3/core/vpConfig.h>
50 #include <visp3/core/vpException.h>
51 #include <visp3/visual_features/vpBasicFeature.h>
52 
53 class vpMomentObject;
54 class vpMomentDatabase;
56 class vpMoment;
57 
135 
159 class VISP_EXPORT vpFeatureMoment : public vpBasicFeature
160 {
161 protected:
162  const vpMoment *moment;
163  const vpMoment &getMoment() const { return *moment; }
166  std::vector<vpMatrix> interaction_matrices;
167 
168  double A;
169  double B;
170  double C;
171  char _name[255];
172 
173  // private:
174  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
175  // vpFeatureMoment(const vpFeatureMoment &fm)
176  // : vpBasicFeature(), moment(NULL), moments(fm.moments),
177  // featureMomentsDataBase(NULL),
178  // interaction_matrices(), A(0), B(0), C(0)
179  // {
180  // throw vpException(vpException::functionNotImplementedError, "Not
181  // implemented!");
182  // }
183  // vpFeatureMoment &operator=(const vpFeatureMoment &){
184  // throw vpException(vpException::functionNotImplementedError, "Not
185  // implemented!"); return *this;
186  // }
187  //#endif
188 
189 public:
204  vpFeatureMoment(vpMomentDatabase &data_base, double A_ = 0.0, double B_ = 0.0, double C_ = 0.0,
205  vpFeatureMomentDatabase *featureMoments = NULL, unsigned int nbmatrices = 1)
206  : vpBasicFeature(), moment(NULL), moments(data_base), featureMomentsDataBase(featureMoments),
207  interaction_matrices(nbmatrices), A(A_), B(B_), C(C_), _name()
208  {
209  }
210 
211  virtual ~vpFeatureMoment();
212 
215  virtual void compute_interaction(void);
216  vpBasicFeature *duplicate() const;
217  void display(const vpCameraParameters &cam, const vpImage<unsigned char> &I, const vpColor &color = vpColor::green,
218  unsigned int thickness = 1) const;
219  void display(const vpCameraParameters &cam, const vpImage<vpRGBa> &I, const vpColor &color = vpColor::green,
220  unsigned int thickness = 1) const;
221 
222  int getDimension(unsigned int select = FEATURE_ALL) const;
223  void init(void);
224  vpMatrix interaction(const unsigned int select = FEATURE_ALL);
225  void linkTo(vpFeatureMomentDatabase &featureMoments);
226 
231  virtual const char *momentName() const = 0;
235  virtual const char *name() const = 0;
236  void print(const unsigned int select = FEATURE_ALL) const;
237  virtual void printDependencies(std::ostream &os) const;
238 
239  void update(double A, double B, double C);
240 
242  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMoment &featM);
243 };
244 
263 class VISP_EXPORT vpMomentGenericFeature : public vpFeatureMoment
264 {
265 public:
266  vpMomentGenericFeature(vpMomentDatabase &data_base, double A_, double B_, double C_,
267  vpFeatureMomentDatabase *featureMoments, const vpMoment *p_moment)
268  : vpFeatureMoment(data_base, A_, B_, C_, featureMoments)
269  {
270  this->moment = p_moment;
271  }
275  const char *momentName() const { return NULL; }
279  virtual const char *name() const { return NULL; }
280 };
281 
282 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:164
const vpMoment * moment
unsigned int getDimension(const unsigned int select=FEATURE_ALL) const
Get the feature vector dimension.
virtual void print(const unsigned int select=FEATURE_ALL) const =0
Print the name of the feature.
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
const char * momentName() const
Class for generic objects.
std::vector< vpMatrix > interaction_matrices
static const vpColor green
Definition: vpColor.h:183
This class defines a generic feature used for moment feature duplication.
class that defines what is a visual feature
This class allows to register all vpMoments so they can access each other according to their dependen...
This class defines shared methods/attributes for 2D moments.
Definition: vpMoment.h:110
This class defines shared system methods/attributes for 2D moment features but no functional code...
virtual vpMatrix interaction(const unsigned int select=FEATURE_ALL)=0
Compute the interaction matrix from a subset of the possible features.
Generic class defining intrinsic camera parameters.
vpMomentDatabase & moments
virtual void init()=0
vpFeatureMomentDatabase * featureMomentsDataBase
vpMomentGenericFeature(vpMomentDatabase &data_base, double A_, double B_, double C_, vpFeatureMomentDatabase *featureMoments, const vpMoment *p_moment)
const vpMoment & getMoment() const
vpFeatureMoment(vpMomentDatabase &data_base, double A_=0.0, double B_=0.0, double C_=0.0, vpFeatureMomentDatabase *featureMoments=NULL, unsigned int nbmatrices=1)
virtual vpBasicFeature * duplicate() const =0
virtual void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const =0
virtual const char * name() const
This class allows to register all feature moments (implemented in vpFeatureMoment... classes) so they can access each other according to their dependencies.