Visual Servoing Platform  version 3.2.1 under development (2019-05-26)
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  void display(const vpImage<vpRGBa> &I);
117 
118  double convolution(const vpImage<unsigned char> &ima, const vpMe *me);
119 
120  vpMeSite *getQueryList(const vpImage<unsigned char> &I, const int range);
121 
122  void track(const vpImage<unsigned char> &im, const vpMe *me, const bool test_contraste = true);
123 
129  void setAlpha(const double &a) { alpha = a; }
130 
136  inline double getAlpha() const { return alpha; }
137 
138  void setDisplay(vpMeSiteDisplayType select) { selectDisplay = select; }
139 
145  inline int get_i() const { return i; }
146 
152  inline int get_j() const { return j; }
153 
159  inline double get_ifloat() const { return ifloat; }
160 
166  inline double get_jfloat() const { return jfloat; }
167 
175  void setState(const vpMeSiteState &flag)
176  {
177  state = flag;
178 
179 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
180  suppress = (int)flag;
181 #endif
182  }
183 
189  inline vpMeSiteState getState() const { return state; }
190 
196  void setWeight(const double &w) { weight = w; }
197 
203  inline double getWeight() const { return weight; }
204 
205  // Operators
206  vpMeSite &operator=(const vpMeSite &m);
207  int operator!=(const vpMeSite &m);
208 
209  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpMeSite &vpMeS);
210 
211  // Static functions
220  static double distance(const vpMeSite &S1, const vpMeSite &S2)
221  {
222  return (sqrt(vpMath::sqr(S1.ifloat - S2.ifloat) + vpMath::sqr(S1.jfloat - S2.jfloat)));
223  }
224 
233  static double sqrDistance(const vpMeSite &S1, const vpMeSite &S2)
234  {
235  return (vpMath::sqr(S1.ifloat - S2.ifloat) + vpMath::sqr(S1.jfloat - S2.jfloat));
236  }
237 
238  static void display(const vpImage<unsigned char> &I, const double &i, const double &j,
239  const vpMeSiteState &state = NO_SUPPRESSION);
240  static void display(const vpImage<vpRGBa> &I, const double &i, const double &j,
241  const vpMeSiteState &state = NO_SUPPRESSION);
242 
243 // Deprecated
244 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
245 public:
248  int suppress;
249 
250  vp_deprecated void getSign(const vpImage<unsigned char> &I, const int range);
251 #endif
252 };
253 
254 #endif
double getAlpha() const
Definition: vpMeSite.h:136
int get_j() const
Definition: vpMeSite.h:152
double get_jfloat() const
Definition: vpMeSite.h:166
double jfloat
Definition: vpMeSite.h:88
static double sqrDistance(const vpMeSite &S1, const vpMeSite &S2)
Definition: vpMeSite.h:233
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:220
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:189
double ifloat
Definition: vpMeSite.h:88
int suppress
Definition: vpMeSite.h:248
int get_i() const
Definition: vpMeSite.h:145
static double sqr(double x)
Definition: vpMath.h:114
void setDisplay(vpMeSiteDisplayType select)
Definition: vpMeSite.h:138
double convlt
Definition: vpMeSite.h:94
unsigned char v
Definition: vpMeSite.h:89
void setState(const vpMeSiteState &flag)
Definition: vpMeSite.h:175
double getWeight() const
Definition: vpMeSite.h:203
int j_1
Definition: vpMeSite.h:87
void setAlpha(const double &a)
Definition: vpMeSite.h:129
int j
Definition: vpMeSite.h:86
double weight
Definition: vpMeSite.h:98
double get_ifloat() const
Definition: vpMeSite.h:159
void setWeight(const double &w)
Definition: vpMeSite.h:196
vpMeSiteState
Definition: vpMeSite.h:76