Visual Servoing Platform  version 3.6.1 under development (2023-10-03)
vpMeSite.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
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 https://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 
39 #ifndef _vpMeSite_h_
40 #define _vpMeSite_h_
41 
42 #include <visp3/core/vpDisplay.h>
43 #include <visp3/core/vpImage.h>
44 #include <visp3/core/vpMatrix.h>
45 #include <visp3/me/vpMe.h>
46 
64 class VISP_EXPORT vpMeSite
65 {
66 public:
70  typedef enum
71  {
72  NONE,
75  RANGE_RESULT
76  } vpMeSiteDisplayType;
77 
81  typedef enum
82  {
83  NO_SUPPRESSION = 0,
84  CONTRAST = 1,
85 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
86  CONSTRAST = CONTRAST,
87 #endif
88  THRESHOLD = 2,
89  M_ESTIMATOR = 3,
90  TOO_NEAR = 4,
91  UNKNOW = 5
92  } vpMeSiteState;
93 
94 public:
96  int i;
98  int j;
100  double ifloat;
102  double jfloat;
106  double alpha;
108  double convlt;
110  double normGradient;
112  double weight;
113 
114 private:
115  vpMeSiteDisplayType selectDisplay;
116  vpMeSiteState state;
117 
118 public:
122  void init();
123 
127  void init(double ip, double jp, double alphap);
128 
132  void init(double ip, double jp, double alphap, double convltp);
133 
137  void init(double ip, double jp, double alphap, double convltp, int sign);
138 
142  vpMeSite();
143 
147  vpMeSite(double ip, double jp);
148 
152  vpMeSite(const vpMeSite &mesite);
153 
157  virtual ~vpMeSite() { };
158 
163  void display(const vpImage<unsigned char> &I);
164 
169  void display(const vpImage<vpRGBa> &I);
170 
174  double convolution(const vpImage<unsigned char> &ima, const vpMe *me);
175 
184  vpMeSite *getQueryList(const vpImage<unsigned char> &I, const int range);
185 
191  void track(const vpImage<unsigned char> &im, const vpMe *me, bool test_likelihood = true);
192 
198  void setAlpha(const double &a) { alpha = a; }
199 
205  inline double getAlpha() const { return alpha; }
206 
210  void setDisplay(vpMeSiteDisplayType select) { selectDisplay = select; }
211 
217  inline int get_i() const { return i; }
218 
224  inline int get_j() const { return j; }
225 
231  inline double get_ifloat() const { return ifloat; }
232 
238  inline double get_jfloat() const { return jfloat; }
239 
247  void setState(const vpMeSiteState &flag)
248  {
249  state = flag;
250 
251 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
252  suppress = (int)flag;
253 #endif
254  }
255 
261  inline vpMeSiteState getState() const { return state; }
262 
268  void setWeight(const double &w) { weight = w; }
269 
275  inline double getWeight() const { return weight; }
276 
280  vpMeSite &operator=(const vpMeSite &m);
281 
285  int operator!=(const vpMeSite &m);
286 
290  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpMeSite &vpMeS);
291 
292  // Static functions
304  static double distance(const vpMeSite &S1, const vpMeSite &S2)
305  {
306  return (sqrt(sqrDistance(S1, S2)));
307  }
308 
320  static double sqrDistance(const vpMeSite &S1, const vpMeSite &S2)
321  {
322  return (vpMath::sqr(S1.ifloat - S2.ifloat) + vpMath::sqr(S1.jfloat - S2.jfloat));
323  }
324 
340  static void display(const vpImage<unsigned char> &I, const double &i, const double &j,
341  const vpMeSiteState &state = NO_SUPPRESSION);
342 
358  static void display(const vpImage<vpRGBa> &I, const double &i, const double &j,
359  const vpMeSiteState &state = NO_SUPPRESSION);
360 
361  // Deprecated
362 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
363 public:
366  int suppress;
367 
368  vp_deprecated void getSign(const vpImage<unsigned char> &I, const int range);
369 #endif
370 };
371 
372 #endif
static double sqr(double x)
Definition: vpMath.h:124
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'....
Definition: vpMeSite.h:65
int j
Coordinates along j of a site.
Definition: vpMeSite.h:98
vpMeSiteState
Definition: vpMeSite.h:82
void setDisplay(vpMeSiteDisplayType select)
Definition: vpMeSite.h:210
double weight
Uncertainty of point given as a probability between 0 and 1.
Definition: vpMeSite.h:112
double ifloat
Floating coordinates along i of a site.
Definition: vpMeSite.h:100
void setAlpha(const double &a)
Definition: vpMeSite.h:198
double getAlpha() const
Definition: vpMeSite.h:205
vpMeSiteDisplayType
Definition: vpMeSite.h:71
@ NONE
Not displayed.
Definition: vpMeSite.h:72
@ RESULT
Definition: vpMeSite.h:74
@ RANGE
Definition: vpMeSite.h:73
int i
Coordinate along i of a site.
Definition: vpMeSite.h:96
static double distance(const vpMeSite &S1, const vpMeSite &S2)
Definition: vpMeSite.h:304
int mask_sign
Mask sign.
Definition: vpMeSite.h:104
void setWeight(const double &w)
Definition: vpMeSite.h:268
int suppress
Definition: vpMeSite.h:366
double normGradient
Convolution of Site in previous image.
Definition: vpMeSite.h:110
double alpha
Angle of tangent at site.
Definition: vpMeSite.h:106
double getWeight() const
Definition: vpMeSite.h:275
double jfloat
Floating coordinates along j of a site.
Definition: vpMeSite.h:102
vpMeSiteState getState() const
Definition: vpMeSite.h:261
double convlt
Convolution of Site in previous image.
Definition: vpMeSite.h:108
int get_j() const
Definition: vpMeSite.h:224
double get_ifloat() const
Definition: vpMeSite.h:231
virtual ~vpMeSite()
Definition: vpMeSite.h:157
int get_i() const
Definition: vpMeSite.h:217
static double sqrDistance(const vpMeSite &S1, const vpMeSite &S2)
Definition: vpMeSite.h:320
double get_jfloat() const
Definition: vpMeSite.h:238
void setState(const vpMeSiteState &flag)
Definition: vpMeSite.h:247
Definition: vpMe.h:122