Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
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 
76  typedef enum {
77  NO_SUPPRESSION = 0,
78  CONSTRAST = 1,
79  THRESHOLD = 2,
80  M_ESTIMATOR = 3,
81  TOO_NEAR = 4,
82  UNKNOW = 5
83  } vpMeSiteState;
84 
85 public:
86  int i, j;
87  int i_1, j_1;
88  double ifloat, jfloat;
89  unsigned char v;
90  int mask_sign;
91  // Angle of tangent at site
92  double alpha;
93  // Convolution of Site in previous image
94  double convlt;
95  // Convolution of Site in previous image
96  double normGradient;
97  // Uncertainty of point given as a probability between 0 and 1
98  double weight;
99 
100 private:
101  vpMeSiteDisplayType selectDisplay;
102  vpMeSiteState state;
103 
104 public:
105  void init();
106  void init(double ip, double jp, double alphap);
107  void init(double ip, double jp, double alphap, double convltp);
108  void init(double ip, double jp, double alphap, double convltp, int sign);
109 
110  vpMeSite();
111  vpMeSite(double ip, double jp);
112  vpMeSite(const vpMeSite &mesite);
113  virtual ~vpMeSite(){};
114 
115  void display(const vpImage<unsigned char> &I);
116 
117  double convolution(const vpImage<unsigned char> &ima, const vpMe *me);
118 
119  vpMeSite *getQueryList(const vpImage<unsigned char> &I, const int range);
120 
121  void track(const vpImage<unsigned char> &im, const vpMe *me, const bool test_contraste = true);
122 
128  void setAlpha(const double &a) { alpha = a; }
129 
135  inline double getAlpha() const { return alpha; }
136 
137  void setDisplay(vpMeSiteDisplayType select) { selectDisplay = select; }
138 
144  inline int get_i() const { return i; }
145 
151  inline int get_j() const { return j; }
152 
158  inline double get_ifloat() const { return ifloat; }
159 
165  inline double get_jfloat() const { return jfloat; }
166 
174  void setState(const vpMeSiteState &flag)
175  {
176  state = flag;
177 
178 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
179  suppress = (int)flag;
180 #endif
181  }
182 
188  inline vpMeSiteState getState() const { return state; }
189 
195  void setWeight(const double &w) { weight = w; }
196 
202  inline double getWeight() const { return weight; }
203 
204  // Operators
205  vpMeSite &operator=(const vpMeSite &m);
206  int operator!=(const vpMeSite &m);
207 
208  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpMeSite &vpMeS);
209 
210  // Static functions
219  static double distance(const vpMeSite &S1, const vpMeSite &S2)
220  {
221  return (sqrt(vpMath::sqr(S1.ifloat - S2.ifloat) + vpMath::sqr(S1.jfloat - S2.jfloat)));
222  }
223 
232  static double sqrDistance(const vpMeSite &S1, const vpMeSite &S2)
233  {
234  return (vpMath::sqr(S1.ifloat - S2.ifloat) + vpMath::sqr(S1.jfloat - S2.jfloat));
235  }
236 
237  static void display(const vpImage<unsigned char> &I, const double &i, const double &j,
238  const vpMeSiteState &state = NO_SUPPRESSION);
239  static void display(const vpImage<vpRGBa> &I, const double &i, const double &j,
240  const vpMeSiteState &state = NO_SUPPRESSION);
241 
242 // Deprecated
243 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
244 public:
247  int suppress;
248 
249  vp_deprecated void getSign(const vpImage<unsigned char> &I, const int range);
250 #endif
251 };
252 
253 #endif
double getAlpha() const
Definition: vpMeSite.h:135
int get_j() const
Definition: vpMeSite.h:151
double get_jfloat() const
Definition: vpMeSite.h:165
double jfloat
Definition: vpMeSite.h:88
static double sqrDistance(const vpMeSite &S1, const vpMeSite &S2)
Definition: vpMeSite.h:232
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:219
double alpha
Definition: vpMeSite.h:92
Definition: vpMe.h:60
int mask_sign
Definition: vpMeSite.h:90
double normGradient
Definition: vpMeSite.h:96
virtual ~vpMeSite()
Definition: vpMeSite.h:113
vpMeSiteDisplayType
Definition: vpMeSite.h:74
vpMeSiteState getState() const
Definition: vpMeSite.h:188
double ifloat
Definition: vpMeSite.h:88
int suppress
Definition: vpMeSite.h:247
int get_i() const
Definition: vpMeSite.h:144
static double sqr(double x)
Definition: vpMath.h:108
void setDisplay(vpMeSiteDisplayType select)
Definition: vpMeSite.h:137
double convlt
Definition: vpMeSite.h:94
unsigned char v
Definition: vpMeSite.h:89
void setState(const vpMeSiteState &flag)
Definition: vpMeSite.h:174
double getWeight() const
Definition: vpMeSite.h:202
int j_1
Definition: vpMeSite.h:87
void setAlpha(const double &a)
Definition: vpMeSite.h:128
int j
Definition: vpMeSite.h:86
double weight
Definition: vpMeSite.h:98
double get_ifloat() const
Definition: vpMeSite.h:158
void setWeight(const double &w)
Definition: vpMeSite.h:195
vpMeSiteState
Definition: vpMeSite.h:76