49 #include <visp3/core/vpTrackingException.h> 50 #include <visp3/me/vpMe.h> 51 #include <visp3/me/vpMeSite.h> 53 #ifndef DOXYGEN_SHOULD_SKIP_THIS 54 static bool horsImage(
int i,
int j,
int half,
int rows,
int cols)
58 int half_1 = half + 1;
59 int half_3 = half + 3;
62 return ((0 < (half_1 - i)) || ((i - rows + half_3) > 0) || (0 < (half_1 - j)) || ((j - cols + half_3) > 0));
90 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS 96 : i(0), j(0),
i_1(0),
j_1(0),
ifloat(0),
jfloat(0),
v(0),
mask_sign(1),
alpha(0.),
convlt(0.),
normGradient(0),
98 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
106 : i(0), j(0),
i_1(0),
j_1(0),
ifloat(0),
jfloat(0),
v(0),
mask_sign(1),
alpha(0.),
convlt(0.),
normGradient(0),
108 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
123 : i(0), j(0),
i_1(0),
j_1(0),
ifloat(0),
jfloat(0),
v(0),
mask_sign(1),
alpha(0.),
convlt(0.),
normGradient(0),
125 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
138 selectDisplay =
NONE;
155 selectDisplay =
NONE;
169 void vpMeSite::init(
double ip,
double jp,
double alphap,
double convltp,
int sign)
171 selectDisplay =
NONE;
199 selectDisplay = m.selectDisplay;
202 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS 226 list_query_pixels = NULL;
228 unsigned int range_ =
static_cast<unsigned int>(range);
230 list_query_pixels =
new vpMeSite[2 * range_ + 1];
235 double salpha = sin(
alpha);
236 double calpha = cos(
alpha);
240 for (k = -range; k <= range; k++) {
241 double ii = (
ifloat + k * salpha);
242 double jj = (
jfloat + k * calpha);
257 list_query_pixels[n] = pel;
261 return (list_query_pixels);
264 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS 279 double salpha = sin(
alpha);
280 double calpha = cos(
alpha);
293 if (I[i1][j1] > I[i2][j2])
304 int height_ =
static_cast<int>(I.
getHeight());
305 int width_ =
static_cast<int>(I.
getWidth());
309 half = (
static_cast<int>(msize) - 1) >> 1;
311 if (horsImage(i, j, half + me->
getStrip(), height_, width_)) {
317 double theta =
alpha + M_PI / 2;
328 if (abs(thetadeg) == 180) {
332 unsigned int index_mask = (
unsigned int)(thetadeg / (
double)me->
getAngleStep());
334 unsigned int i_ =
static_cast<unsigned int>(
i);
335 unsigned int j_ =
static_cast<unsigned int>(
j);
336 unsigned int half_ =
static_cast<unsigned int>(half);
338 unsigned int ihalf = i_ - half_;
339 unsigned int jhalf = j_ - half_;
341 for (
unsigned int a = 0; a < msize; a++) {
342 unsigned int ihalfa = ihalf + a;
343 for (
unsigned int b = 0; b < msize; b++) {
346 I(ihalfa, jhalf + b);
492 double max_convolution = 0;
494 double contraste = 0;
501 unsigned int range = me->
getRange();
507 double contraste_max = 1 + me->
getMu2();
508 double contraste_min = 1 - me->
getMu1();
511 double *likelihood =
new double[2 * range + 1];
522 for (
unsigned int n = 0; n < 2 * range + 1; n++) {
524 double convolution_ = list_query_pixels[n].
convolution(I, me);
529 if (test_contraste) {
530 likelihood[n] = fabs(convolution_ +
convlt);
531 if (likelihood[n] > threshold) {
532 contraste = convolution_ /
convlt;
533 if ((contraste > contraste_min) && (contraste < contraste_max) && fabs(1 - contraste) < diff) {
534 diff = fabs(1 - contraste);
535 max_convolution = convolution_;
545 likelihood[n] = fabs(2 * convolution_);
546 if (likelihood[n] > max && likelihood[n] > threshold) {
547 max_convolution = convolution_;
564 ip.
set_i(list_query_pixels[max_rank].i);
565 ip.
set_j(list_query_pixels[max_rank].j);
569 *
this = list_query_pixels[max_rank];
576 delete[] list_query_pixels;
581 ip.
set_i(list_query_pixels[0].i);
582 ip.
set_j(list_query_pixels[0].j);
587 if (std::fabs(contraste) > std::numeric_limits<double>::epsilon())
592 delete[] list_query_pixels;
601 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS 602 return (os <<
"Alpha: " << vpMeS.
alpha <<
" Convolution: " << vpMeS.
convlt <<
" Flag: " << vpMeS.
suppress 603 <<
" Weight: " << vpMeS.
weight);
605 return (os <<
"Alpha: " << vpMeS.
alpha <<
" Convolution: " << vpMeS.
convlt <<
" Weight: " << vpMeS.
weight);
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, vpMeSite &vpMeS)
void display(const vpImage< unsigned char > &I)
double convolution(const vpImage< unsigned char > &ima, const vpMe *me)
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'...
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static const vpColor green
vpMatrix * getMask() const
static int round(const double x)
unsigned int getMaskSize() const
void set_i(const double ii)
static const vpColor cyan
double getThreshold() const
static double sqr(double x)
void setDisplay(vpMeSiteDisplayType select)
vpMeSite * getQueryList(const vpImage< unsigned char > &I, const int range)
vp_deprecated void getSign(const vpImage< unsigned char > &I, const int range)
void set_j(const double jj)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
unsigned int getHeight() const
vpMeSite & operator=(const vpMeSite &m)
void track(const vpImage< unsigned char > &im, const vpMe *me, const bool test_contraste=true)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static const vpColor yellow
static const vpColor purple
unsigned int getWidth() const
unsigned int getRange() const
int operator!=(const vpMeSite &m)
unsigned int getAngleStep() const
static const vpColor blue