Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
vpMeSite.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  * Moving edges.
33  *
34  * Authors:
35  * Eric Marchand
36  * Andrew Comport
37  * Aurelien Yol
38  *
39  *****************************************************************************/
40 
46 #ifndef vpMeSite_H
47 #define vpMeSite_H
48 
49 #include <visp3/core/vpDisplay.h>
50 #include <visp3/core/vpImage.h>
51 #include <visp3/core/vpMatrix.h>
52 #include <visp3/me/vpMe.h>
53 
71 class VISP_EXPORT vpMeSite
72 {
73 public:
74  typedef enum { NONE, RANGE, RESULT, RANGE_RESULT } vpMeSiteDisplayType;
75 
77  typedef enum {
78  NO_SUPPRESSION = 0,
79  CONSTRAST = 1,
80  THRESHOLD = 2,
81  M_ESTIMATOR = 3,
82  TOO_NEAR = 4,
83  UNKNOW = 5
84  } vpMeSiteState;
85 
86 public:
87  int i, j;
88  int i_1, j_1;
89  double ifloat, jfloat;
90  unsigned char v;
91  int mask_sign;
92  // Angle of tangent at site
93  double alpha;
94  // Convolution of Site in previous image
95  double convlt;
96  // Convolution of Site in previous image
97  double normGradient;
98  // Uncertainty of point given as a probability between 0 and 1
99  double weight;
100 
101 private:
102  vpMeSiteDisplayType selectDisplay;
103  vpMeSiteState state;
104 
105 public:
106  void init();
107  void init(double ip, double jp, double alphap);
108  void init(double ip, double jp, double alphap, double convltp);
109  void init(double ip, double jp, double alphap, double convltp, int sign);
110 
111  vpMeSite();
112  vpMeSite(double ip, double jp);
113  vpMeSite(const vpMeSite &mesite);
114  virtual ~vpMeSite(){};
115 
116  void display(const vpImage<unsigned char> &I);
117  void display(const vpImage<vpRGBa> &I);
118 
119  double convolution(const vpImage<unsigned char> &ima, const vpMe *me);
120 
121  vpMeSite *getQueryList(const vpImage<unsigned char> &I, const int range);
122 
123  void track(const vpImage<unsigned char> &im, const vpMe *me, bool test_contraste = true);
124 
130  void setAlpha(const double &a) { alpha = a; }
131 
137  inline double getAlpha() const { return alpha; }
138 
139  void setDisplay(vpMeSiteDisplayType select) { selectDisplay = select; }
140 
146  inline int get_i() const { return i; }
147 
153  inline int get_j() const { return j; }
154 
160  inline double get_ifloat() const { return ifloat; }
161 
167  inline double get_jfloat() const { return jfloat; }
168 
176  void setState(const vpMeSiteState &flag)
177  {
178  state = flag;
179 
180 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
181  suppress = (int)flag;
182 #endif
183  }
184 
190  inline vpMeSiteState getState() const { return state; }
191 
197  void setWeight(const double &w) { weight = w; }
198 
204  inline double getWeight() const { return weight; }
205 
206  // Operators
207  vpMeSite &operator=(const vpMeSite &m);
208  int operator!=(const vpMeSite &m);
209 
210  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpMeSite &vpMeS);
211 
212  // Static functions
221  static double distance(const vpMeSite &S1, const vpMeSite &S2)
222  {
223  return (sqrt(vpMath::sqr(S1.ifloat - S2.ifloat) + vpMath::sqr(S1.jfloat - S2.jfloat)));
224  }
225 
234  static double sqrDistance(const vpMeSite &S1, const vpMeSite &S2)
235  {
236  return (vpMath::sqr(S1.ifloat - S2.ifloat) + vpMath::sqr(S1.jfloat - S2.jfloat));
237  }
238 
239  static void display(const vpImage<unsigned char> &I, const double &i, const double &j,
240  const vpMeSiteState &state = NO_SUPPRESSION);
241  static void display(const vpImage<vpRGBa> &I, const double &i, const double &j,
242  const vpMeSiteState &state = NO_SUPPRESSION);
243 
244 // Deprecated
245 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
246 public:
249  int suppress;
250 
251  vp_deprecated void getSign(const vpImage<unsigned char> &I, const int range);
252 #endif
253 };
254 
255 #endif
vpMeSiteState getState() const
Definition: vpMeSite.h:190
double jfloat
Definition: vpMeSite.h:89
int get_j() const
Definition: vpMeSite.h:153
static double sqrDistance(const vpMeSite &S1, const vpMeSite &S2)
Definition: vpMeSite.h:234
int get_i() const
Definition: vpMeSite.h:146
Performs search in a given direction(normal) for a given distance(pixels) for a given &#39;site&#39;...
Definition: vpMeSite.h:71
static double distance(const vpMeSite &S1, const vpMeSite &S2)
Definition: vpMeSite.h:221
double alpha
Definition: vpMeSite.h:93
double getAlpha() const
Definition: vpMeSite.h:137
Definition: vpMe.h:60
int mask_sign
Definition: vpMeSite.h:91
double normGradient
Definition: vpMeSite.h:97
virtual ~vpMeSite()
Definition: vpMeSite.h:114
vpMeSiteDisplayType
Definition: vpMeSite.h:74
double ifloat
Definition: vpMeSite.h:89
int suppress
Definition: vpMeSite.h:249
static double sqr(double x)
Definition: vpMath.h:114
void setDisplay(vpMeSiteDisplayType select)
Definition: vpMeSite.h:139
double get_jfloat() const
Definition: vpMeSite.h:167
double convlt
Definition: vpMeSite.h:95
unsigned char v
Definition: vpMeSite.h:90
void setState(const vpMeSiteState &flag)
Definition: vpMeSite.h:176
int j_1
Definition: vpMeSite.h:88
double getWeight() const
Definition: vpMeSite.h:204
void setAlpha(const double &a)
Definition: vpMeSite.h:130
int j
Definition: vpMeSite.h:87
double weight
Definition: vpMeSite.h:99
double get_ifloat() const
Definition: vpMeSite.h:160
void setWeight(const double &w)
Definition: vpMeSite.h:197
vpMeSiteState
Moving-edge site state.
Definition: vpMeSite.h:77