Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMeSite.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  * Moving edges.
32  *
33  * Authors:
34  * Eric Marchand
35  * Andrew Comport
36  * Aurelien Yol
37  *
38  *****************************************************************************/
39 
47 #ifndef vpMeSite_H
48 #define vpMeSite_H
49 
50 #include <visp3/core/vpMatrix.h>
51 #include <visp3/core/vpImage.h>
52 #include <visp3/core/vpDisplay.h>
53 #include <visp3/me/vpMe.h>
54 
72 class VISP_EXPORT vpMeSite
73 {
74 public:
75  typedef enum
76  {
80  RANGE_RESULT
81  } vpMeSiteDisplayType;
82 
83  typedef enum
84  {
85  NO_SUPPRESSION = 0,
86  CONSTRAST = 1,
87  THRESHOLD = 2,
88  M_ESTIMATOR = 3,
89  TOO_NEAR = 4,
90  UNKNOW = 5
91  } vpMeSiteState;
92 
93 public:
94  int i,j ;
95  int i_1, j_1 ;
96  double ifloat, jfloat ;
97  unsigned char v ;
98  int mask_sign ;
99  // Angle of tangent at site
100  double alpha;
101  // Convolution of Site in previous image
102  double convlt ;
103  // Convolution of Site in previous image
104  double normGradient ;
105  // Uncertainty of point given as a probability between 0 and 1
106  double weight;
107 
108 private:
109  vpMeSiteDisplayType selectDisplay ;
110  vpMeSiteState state;
111 
112 public:
113  void init() ;
114  void init(double ip, double jp, double alphap) ;
115  void init(double ip, double jp, double alphap, double convltp) ;
116  void init(double ip, double jp, double alphap, double convltp, int sign) ;
117 
118  vpMeSite () ;
119  vpMeSite(double ip, double jp) ;
120  vpMeSite (const vpMeSite &mesite) ;
121  virtual ~vpMeSite() {} ;
122 
123  void display(const vpImage<unsigned char>& I);
124 
125  double convolution(const vpImage<unsigned char>& ima, const vpMe *me) ;
126 
127  vpMeSite *getQueryList(const vpImage<unsigned char> &I, const int range) ;
128 
129  void track(const vpImage<unsigned char>& im,
130  const vpMe *me,
131  const bool test_contraste=true);
132 
138  void setAlpha(const double &a) { alpha = a; }
139 
145  inline double getAlpha() const { return alpha; }
146 
147 
148  void setDisplay(vpMeSiteDisplayType select) { selectDisplay = select ; }
149 
155  inline int get_i() const { return i; }
156 
162  inline int get_j() const { return j; }
163 
169  inline double get_ifloat() const { return ifloat; }
170 
176  inline double get_jfloat() const { return jfloat; }
177 
185  void setState(const vpMeSiteState &flag){
186  state = flag;
187 
188  #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
189  suppress = (int)flag;
190  #endif
191  }
192 
198  inline vpMeSiteState getState() const { return state; }
199 
205  void setWeight(const double &w) { weight = w; }
206 
212  inline double getWeight() const { return weight; }
213 
214 //Operators
215  vpMeSite &operator=(const vpMeSite &m) ;
216  int operator!=(const vpMeSite &m) ;
217 
218  friend VISP_EXPORT std::ostream& operator<<(std::ostream& os, vpMeSite& vpMeS);
219 
220 //Static functions
229  static double distance (const vpMeSite S1, const vpMeSite S2) {
230  return(sqrt(vpMath::sqr(S1.ifloat-S2.ifloat)+vpMath::sqr(S1.jfloat-S2.jfloat)));}
231 
240  static double sqrDistance (const vpMeSite S1, const vpMeSite S2) {
241  return(vpMath::sqr(S1.ifloat-S2.ifloat)+vpMath::sqr(S1.jfloat-S2.jfloat));}
242 
243  static void display(const vpImage<unsigned char>& I, const double &i, const double &j,
244  const vpMeSiteState &state = NO_SUPPRESSION);
245  static void display(const vpImage<vpRGBa>& I, const double &i, const double &j,
246  const vpMeSiteState &state = NO_SUPPRESSION);
247 
248 //Deprecated
249 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
250 public:
253  int suppress;
254 
255  vp_deprecated void getSign(const vpImage<unsigned char> &I, const int range) ;
256 #endif
257 } ;
258 
259 #endif
double getAlpha() const
Definition: vpMeSite.h:145
int get_j() const
Definition: vpMeSite.h:162
static double distance(const vpMeSite S1, const vpMeSite S2)
Definition: vpMeSite.h:229
double get_jfloat() const
Definition: vpMeSite.h:176
double jfloat
Definition: vpMeSite.h:96
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'...
Definition: vpMeSite.h:72
double alpha
Definition: vpMeSite.h:100
Definition: vpMe.h:59
int mask_sign
Definition: vpMeSite.h:98
double normGradient
Definition: vpMeSite.h:104
virtual ~vpMeSite()
Definition: vpMeSite.h:121
vpMeSiteDisplayType
Definition: vpMeSite.h:75
vpMeSiteState getState() const
Definition: vpMeSite.h:198
double ifloat
Definition: vpMeSite.h:96
int suppress
Definition: vpMeSite.h:253
int get_i() const
Definition: vpMeSite.h:155
static double sqr(double x)
Definition: vpMath.h:110
void setDisplay(vpMeSiteDisplayType select)
Definition: vpMeSite.h:148
double convlt
Definition: vpMeSite.h:102
static double sqrDistance(const vpMeSite S1, const vpMeSite S2)
Definition: vpMeSite.h:240
unsigned char v
Definition: vpMeSite.h:97
void setState(const vpMeSiteState &flag)
Definition: vpMeSite.h:185
double getWeight() const
Definition: vpMeSite.h:212
int j_1
Definition: vpMeSite.h:95
void setAlpha(const double &a)
Definition: vpMeSite.h:138
int j
Definition: vpMeSite.h:94
double weight
Definition: vpMeSite.h:106
double get_ifloat() const
Definition: vpMeSite.h:169
void setWeight(const double &w)
Definition: vpMeSite.h:205
vpMeSiteState
Definition: vpMeSite.h:83