Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpMeSite.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 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
38
39#ifndef VP_ME_SITE_H
40#define VP_ME_SITE_H
41
42#include <visp3/core/vpConfig.h>
43#include <visp3/core/vpDisplay.h>
44#include <visp3/core/vpImage.h>
45#include <visp3/core/vpMatrix.h>
46#include <visp3/me/vpMe.h>
47
49
74class VISP_EXPORT vpMeSite
75{
76public:
80 typedef enum
81 {
86 } vpMeSiteDisplayType;
87
91 typedef enum
92 {
95#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
97#endif
101 UNKNOW = 5,
103 } vpMeSiteState;
104
106 int m_i;
108 int m_j;
110 double m_ifloat;
112 double m_jfloat;
116 double m_alpha;
118 double m_convlt;
122 double m_weight;
125
126public:
130 vpMeSite();
131
135 vpMeSite(const double &ip, const double &jp);
136
140 vpMeSite(const vpMeSite &mesite);
141
145 virtual ~vpMeSite() { }
146
150 double convolution(const vpImage<unsigned char> &ima, const vpMe *me);
151
155 double convolution(const vpImage<unsigned char> &ima, const vpMe &me, const unsigned int mask_index);
156
160 unsigned int computeMaskIndex(const double alpha, const vpMe &me);
161
166 void display(const vpImage<unsigned char> &I) const;
167
172 void display(const vpImage<vpRGBa> &I) const;
173
179 inline double getAlpha() const { return m_alpha; }
180
184 inline double getWeight() const { return m_weight; }
185
194 vpMeSite *getQueryList(const vpImage<unsigned char> &I, const int &range) const;
195
200 inline int get_i() const { return m_i; }
201
206 inline int get_j() const { return m_j; }
207
212 inline double get_ifloat() const { return m_ifloat; }
213
218 inline double get_jfloat() const { return m_jfloat; }
219
224 inline unsigned int getIndex() const { return m_index_prev; }
225
229 void init();
230
234 void init(const double &ip, const double &jp, const double &alphap);
235
239 void init(const double &ip, const double &jp, const double &alphap, const double &convltp);
240
244 void init(const double &ip, const double &jp, const double &alphap, const double &convltp, const int &sign);
245
249 void init(const double &ip, const double &jp, const double &alphap, const double &convltp, const int &sign, const double &contrastThreshold);
250
261 void track(const vpImage<unsigned char> &I, const vpMe *me, const bool &test_contrast = true);
262
274 void trackMultipleHypotheses(const vpImage<unsigned char> &I, const vpMe &me, const bool &test_contrast,
275 std::vector<vpMeSite> &outputHypotheses, const unsigned numCandidates);
276
282 void setAlpha(const double &a) { m_alpha = a; }
283
287 void setDisplay(vpMeSiteDisplayType select) { m_selectDisplay = select; }
288
296 void setState(const vpMeSiteState &flag)
297 {
298 m_state = flag;
299 }
300
306 inline vpMeSiteState getState() const { return m_state; }
307
313 void setWeight(const double &weight) { m_weight = weight; }
314
326 void setContrastThreshold(const double &thresh, const vpMe &me)
327 {
328 double threshold;
329 if (me.getUseAutomaticThreshold()) {
330 threshold = std::max(thresh, me.getMinThreshold());
331 }
332 else {
333 threshold = me.getThreshold();
334 }
335
336 m_contrastThreshold = threshold;
337 }
338
344 inline double getContrastThreshold() const { return m_contrastThreshold; }
345
346
352 inline double computeFinalThreshold(const vpMe &me) const
353 {
354 const double threshold = getContrastThreshold();
356 return 2.0 * threshold;
357 }
358 else {
359 const double n_d = me.getMaskSize();
360 return threshold / (100.0 * n_d * trunc(n_d / 2.0));
361 }
362 }
363
367 vpMeSite &operator=(const vpMeSite &m);
368
372 int operator!=(const vpMeSite &m);
373
377 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpMeSite &vpMeS);
378
379 // Static functions
391 static double distance(const vpMeSite &S1, const vpMeSite &S2)
392 {
393 return (sqrt(sqrDistance(S1, S2)));
394 }
395
407 static double sqrDistance(const vpMeSite &S1, const vpMeSite &S2)
408 {
409 return (vpMath::sqr(S1.m_ifloat - S2.m_ifloat) + vpMath::sqr(S1.m_jfloat - S2.m_jfloat));
410 }
411
427 static void display(const vpImage<unsigned char> &I, const double &i, const double &j,
428 const vpMeSiteState &state = NO_SUPPRESSION);
429
445 static void display(const vpImage<vpRGBa> &I, const double &i, const double &j,
446 const vpMeSiteState &state = NO_SUPPRESSION);
447
448private:
449 vpMeSiteDisplayType m_selectDisplay;
450 vpMeSiteState m_state;
451 unsigned int m_index_prev;
452};
453
454END_VISP_NAMESPACE
455
456#endif
Definition of the vpImage class member functions.
Definition vpImage.h:131
static double sqr(double x)
Definition vpMath.h:203
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'....
Definition vpMeSite.h:75
int m_mask_sign
Mask sign.
Definition vpMeSite.h:114
vpMeSiteState
Definition vpMeSite.h:92
@ OUTSIDE_ROI_MASK
Point is outside the region of interest mask, but retained in the ME list.
Definition vpMeSite.h:102
@ CONSTRAST
Deprecated. Point not tracked due to a likelihood problem, but retained in the ME list....
Definition vpMeSite.h:96
@ UNKNOW
Reserved.
Definition vpMeSite.h:101
@ TOO_NEAR
Point not tracked anymore, since too near from its neighbor.
Definition vpMeSite.h:100
@ THRESHOLD
Point not tracked due to the likelihood that is below the threshold, but retained in the ME list.
Definition vpMeSite.h:98
@ CONTRAST
Point not tracked due to a contrast problem, but retained in the ME list.
Definition vpMeSite.h:94
@ M_ESTIMATOR
Point detected as an outlier during virtual visual-servoing.
Definition vpMeSite.h:99
@ NO_SUPPRESSION
Point successfully tracked.
Definition vpMeSite.h:93
void setDisplay(vpMeSiteDisplayType select)
Definition vpMeSite.h:287
double m_ifloat
Subpixel coordinates along i of a site.
Definition vpMeSite.h:110
double m_normGradient
Convolution of Site in previous image.
Definition vpMeSite.h:120
void setAlpha(const double &a)
Definition vpMeSite.h:282
double getAlpha() const
Definition vpMeSite.h:179
double getContrastThreshold() const
Definition vpMeSite.h:344
double m_convlt
Convolution of Site in previous image.
Definition vpMeSite.h:118
void setWeight(const double &weight)
Definition vpMeSite.h:313
double m_alpha
Angle of tangent at site.
Definition vpMeSite.h:116
vpMeSiteDisplayType
Definition vpMeSite.h:81
@ NONE
Not displayed.
Definition vpMeSite.h:82
@ RANGE_RESULT
Definition vpMeSite.h:85
static double distance(const vpMeSite &S1, const vpMeSite &S2)
Definition vpMeSite.h:391
unsigned int getIndex() const
Definition vpMeSite.h:224
double computeFinalThreshold(const vpMe &me) const
Definition vpMeSite.h:352
double m_contrastThreshold
Old likelihood ratio threshold (to be avoided) or easy-to-use normalized threshold: minimal contrast.
Definition vpMeSite.h:124
double getWeight() const
Definition vpMeSite.h:184
vpMeSiteState getState() const
Definition vpMeSite.h:306
int m_j
Integer coordinates along j of a site.
Definition vpMeSite.h:108
int get_j() const
Definition vpMeSite.h:206
int m_i
Integer coordinate along i of a site.
Definition vpMeSite.h:106
double get_ifloat() const
Definition vpMeSite.h:212
double m_jfloat
Subpixel coordinates along j of a site.
Definition vpMeSite.h:112
virtual ~vpMeSite()
Definition vpMeSite.h:145
int get_i() const
Definition vpMeSite.h:200
static double sqrDistance(const vpMeSite &S1, const vpMeSite &S2)
Definition vpMeSite.h:407
double m_weight
Uncertainty of point given as a probability between 0 and 1.
Definition vpMeSite.h:122
double get_jfloat() const
Definition vpMeSite.h:218
void setContrastThreshold(const double &thresh, const vpMe &me)
Definition vpMeSite.h:326
void setState(const vpMeSiteState &flag)
Definition vpMeSite.h:296
Definition vpMe.h:143
bool getUseAutomaticThreshold() const
Indicates if the contrast threshold of the vpMeSite is automatically computed.
Definition vpMe.h:333
vpLikelihoodThresholdType getLikelihoodThresholdType() const
Definition vpMe.h:342
double getThreshold() const
Definition vpMe.h:306
unsigned int getMaskSize() const
Definition vpMe.h:240
@ NORMALIZED_THRESHOLD
Definition vpMe.h:154
double getMinThreshold() const
Definition vpMe.h:325