Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpFeatureMoment.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Authors:
34  * Filip Novotny
35  *
36  *****************************************************************************/
43 #ifndef __FEATUREMOMENT_H__
44 #define __FEATUREMOMENT_H__
45 
46 #include <visp3/core/vpConfig.h>
47 #include <visp3/visual_features/vpBasicFeature.h>
48 #include <visp3/core/vpException.h>
49 #include <vector>
50 
51 class vpMomentObject;
52 class vpMomentDatabase;
54 class vpMoment;
55 
115 
139 class VISP_EXPORT vpFeatureMoment : public vpBasicFeature
140 {
141 protected:
142  const vpMoment* moment;
143  const vpMoment& getMoment() const {return *moment;}
146  std::vector<vpMatrix> interaction_matrices;
147 
148  double A;
149  double B;
150  double C;
151  char _name[255];
152 
153 //private:
154 //#ifndef DOXYGEN_SHOULD_SKIP_THIS
155 // vpFeatureMoment(const vpFeatureMoment &fm)
156 // : vpBasicFeature(), moment(NULL), moments(fm.moments), featureMomentsDataBase(NULL),
157 // interaction_matrices(), A(0), B(0), C(0)
158 // {
159 // throw vpException(vpException::functionNotImplementedError, "Not implemented!");
160 // }
161 // vpFeatureMoment &operator=(const vpFeatureMoment &){
162 // throw vpException(vpException::functionNotImplementedError, "Not implemented!");
163 // return *this;
164 // }
165 //#endif
166 
167 public:
177  vpFeatureMoment(vpMomentDatabase& data_base,double A_=0.0, double B_=0.0, double C_=0.0,
178  vpFeatureMomentDatabase* featureMoments=NULL,unsigned int nbmatrices=1)
179  : vpBasicFeature(), moment(NULL),
180  moments(data_base),
181  featureMomentsDataBase(featureMoments),
182  interaction_matrices(nbmatrices),
183  A(A_),B(B_),C(C_)
184  {}
185 
186  virtual ~vpFeatureMoment();
187 
190  virtual void compute_interaction (void);
191  vpBasicFeature* duplicate () const;
192  void display (const vpCameraParameters &cam, const vpImage< unsigned char > &I,
193  const vpColor &color=vpColor::green, unsigned int thickness=1) const ;
194  void display (const vpCameraParameters &cam, const vpImage< vpRGBa > &I,
195  const vpColor &color=vpColor::green, unsigned int thickness=1) const ;
196 
197  int getDimension (unsigned int select=FEATURE_ALL) const;
198  void init (void);
199  vpMatrix interaction (const unsigned int select=FEATURE_ALL) ;
200  void linkTo(vpFeatureMomentDatabase& featureMoments);
201 
206  virtual const char* momentName() const = 0;
210  virtual const char* name() const = 0;
211  void print (const unsigned int select=FEATURE_ALL) const ;
212  virtual void printDependencies(std::ostream& os) const;
213 
214  void update (double A, double B, double C);
215 
217  friend VISP_EXPORT std::ostream& operator<<(std::ostream & os, const vpFeatureMoment& featM);
218 };
219 
234 class VISP_EXPORT vpMomentGenericFeature : public vpFeatureMoment{
235 public:
236  vpMomentGenericFeature(vpMomentDatabase& data_base,double A_, double B_, double C_,
237  vpFeatureMomentDatabase* featureMoments, const vpMoment* p_moment)
238  : vpFeatureMoment(data_base,A_,B_,C_,featureMoments){this->moment = p_moment;}
242  const char* momentName() const { return NULL;}
246  virtual const char* name() const { return NULL;}
247 };
248 
249 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
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:121
const char * momentName() const
Class for generic objects.
std::vector< vpMatrix > interaction_matrices
static const vpColor green
Definition: vpColor.h:166
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:106
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.