47 #include <visp3/me/vpMeSite.h>
48 #include <visp3/me/vpMe.h>
49 #include <visp3/core/vpTrackingException.h>
53 #include <visp3/me/vpMeSite.h>
56 #ifndef DOXYGEN_SHOULD_SKIP_THIS
58 bool horsImage(
int i ,
int j,
int half,
int rows,
int cols)
61 int half_1 = half + 1;
62 int half_3 = half + 3;
64 return( (0 < (half_1 - i) ) || ( (i - rows + half_3) > 0 ) || ( 0 < (half_1 -j) ) || ( (j - cols + half_3) > 0 ) ) ;
76 selectDisplay =
NONE ;
93 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
99 : i(0), j(0), i_1(0), j_1(0), ifloat(0), jfloat(0), v(0), mask_sign(1), alpha(0.),
100 convlt(0.), normGradient(0), weight(1), selectDisplay(NONE), state(NO_SUPPRESSION)
101 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
108 : i(0), j(0), i_1(0), j_1(0), ifloat(0), jfloat(0), v(0), mask_sign(1), alpha(0.),
109 convlt(0.), normGradient(0), weight(1), selectDisplay(NONE), state(NO_SUPPRESSION)
110 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
124 : i(0), j(0), i_1(0), j_1(0), ifloat(0), jfloat(0), v(0), mask_sign(1), alpha(0.),
125 convlt(0.), normGradient(0), weight(1), selectDisplay(NONE), state(NO_SUPPRESSION)
126 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
139 selectDisplay =
NONE ;
158 selectDisplay =
NONE ;
175 selectDisplay =
NONE ;
203 selectDisplay = m.selectDisplay;
206 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
232 list_query_pixels = NULL ;
234 unsigned int range_ =
static_cast<unsigned int>(range);
236 list_query_pixels =
new vpMeSite[2 * range_ + 1] ;
241 double salpha = sin(
alpha);
242 double calpha = cos(
alpha);
246 for(k = -range ; k <= range ; k++)
248 double ii = (
ifloat+k*salpha);
249 double jj = (
jfloat+k*calpha);
264 list_query_pixels[n] = pel ;
268 return(list_query_pixels) ;
271 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
287 double salpha = sin(
alpha);
288 double calpha = cos(
alpha);
310 int height_ =
static_cast<int>(I.
getHeight());
311 int width_ =
static_cast<int>(I.
getWidth());
315 half = (
static_cast<int>(msize) - 1) >> 1 ;
317 if(horsImage( i , j , half + me->
getStrip() , height_, width_))
325 double theta =
alpha+M_PI/2;
328 while (theta<0) theta += M_PI;
329 while (theta>M_PI) theta -= M_PI;
334 if(abs(thetadeg) == 180 )
339 unsigned int index_mask = (
unsigned int)(thetadeg/(
double)me->
getAngleStep());
341 unsigned int i_ =
static_cast<unsigned int>(
i);
342 unsigned int j_ =
static_cast<unsigned int>(
j);
343 unsigned int half_ =
static_cast<unsigned int>(half);
345 unsigned int ihalf = i_-half_ ;
346 unsigned int jhalf = j_-half_ ;
348 for(
unsigned int a = 0 ; a < msize ; a++ )
350 unsigned int ihalfa = ihalf+a ;
351 for(
unsigned int b = 0 ; b < msize ; b++ )
376 const bool test_contraste)
504 double max_convolution = 0 ;
506 double contraste = 0;
513 unsigned int range = me->
getRange() ;
518 double contraste_max = 1 + me->
getMu2();
519 double contraste_min = 1 - me->
getMu1();
522 double *likelihood=
new double[ 2 * range + 1 ] ;
533 for(
unsigned int n = 0 ; n < 2 * range + 1 ; n++)
536 double convolution_ = list_query_pixels[n].
convolution(I, me) ;
543 likelihood[n] = fabs(convolution_ +
convlt );
544 if (likelihood[n]> threshold)
546 contraste = convolution_ /
convlt;
547 if((contraste > contraste_min) && (contraste < contraste_max) && fabs(1-contraste) < diff)
549 diff = fabs(1-contraste);
550 max_convolution= convolution_;
551 max = likelihood[n] ;
561 likelihood[n] = fabs(2*convolution_) ;
562 if (likelihood[n] > max && likelihood[n] > threshold)
564 max_convolution= convolution_;
565 max = likelihood[n] ;
583 ip.
set_i( list_query_pixels[max_rank].i );
584 ip.
set_j( list_query_pixels[max_rank].j );
588 *
this = list_query_pixels[max_rank] ;
594 delete []list_query_pixels ;
601 ip.
set_i( list_query_pixels[0].i );
602 ip.
set_j( list_query_pixels[0].j );
607 if(std::fabs(contraste) > std::numeric_limits<double>::epsilon())
612 delete []list_query_pixels ;
619 return((m.
i != i) || (m.
j != j)) ;
625 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
626 return (os <<
"Alpha: " << vpMeS.
alpha
627 <<
" Convolution: " << vpMeS.
convlt
629 <<
" Weight: " << vpMeS.
weight );
631 return (os <<
"Alpha: " << vpMeS.
alpha
632 <<
" Convolution: " << vpMeS.
convlt
633 <<
" Weight: " << vpMeS.
weight );
unsigned int getRange() const
unsigned int getMaskSize() const
unsigned int getWidth() const
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
static int round(const double x)
double getThreshold() const
void set_i(const double ii)
unsigned int getAngleStep() const
static const vpColor cyan
static double sqr(double x)
void setDisplay(vpMeSiteDisplayType select)
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
vpMeSite * getQueryList(const vpImage< unsigned char > &I, const int range)
vp_deprecated void getSign(const vpImage< unsigned char > &I, const int range)
vpMatrix * getMask() const
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)
vpMeSite & operator=(const vpMeSite &m)
void track(const vpImage< unsigned char > &im, const vpMe *me, const bool test_contraste=true)
unsigned int getHeight() const
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
int operator!=(const vpMeSite &m)
static const vpColor blue