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 101 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
110 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
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 );
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