51 #include <visp/vpMeSite.h>
52 #include <visp/vpMe.h>
53 #include <visp/vpTrackingException.h>
60 #ifndef DOXYGEN_SHOULD_SKIP_THIS
62 bool horsImage(
int i ,
int j,
int half,
int rows,
int cols)
65 int half_1 = half + 1;
66 int half_3 = half + 3;
68 return( (0 < (half_1 - i) ) || ( (i - rows + half_3) > 0 ) || ( 0 < (half_1 -j) ) || ( (j - cols + half_3) > 0 ) ) ;
80 selectDisplay =
NONE ;
97 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
111 selectDisplay =
NONE ;
132 selectDisplay =
NONE ;
151 selectDisplay =
NONE ;
168 selectDisplay =
NONE ;
196 selectDisplay = m.selectDisplay;
199 #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++)
258 list_query_pixels[n] = pel ;
262 return(list_query_pixels) ;
265 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
281 double salpha = sin(
alpha);
282 double calpha = cos(
alpha);
304 unsigned int index_mask ;
305 int height_ =
static_cast<int>(I.
getHeight());
306 int width_ =
static_cast<int>(I.
getWidth());
310 half = (
static_cast<int>(msize) - 1) >> 1 ;
312 if(horsImage( i , j , half + me->
getStrip() , height_, width_))
320 double theta =
alpha+M_PI/2;
323 while (theta<0) theta += M_PI;
324 while (theta>M_PI) theta -= M_PI;
329 if(abs(thetadeg) == 180 )
334 index_mask = (
unsigned int)(thetadeg/(
double)me->
getAngleStep());
336 unsigned int i_ =
static_cast<unsigned int>(
i);
337 unsigned int j_ =
static_cast<unsigned int>(
j);
338 unsigned int half_ =
static_cast<unsigned int>(half);
340 unsigned int ihalf = i_-half_ ;
341 unsigned int jhalf = j_-half_ ;
342 unsigned int ihalfa ;
344 for(
unsigned int a = 0 ; a < msize ; a++ )
347 for(
unsigned int b = 0 ; b < msize ; b++ )
372 const bool test_contraste)
501 double max_convolution = 0 ;
503 double contraste = 0;
510 unsigned int range = me->
getRange() ;
515 double contraste_max = 1 + me->
getMu2();
516 double contraste_min = 1 - me->
getMu1();
519 double *likelihood=
new double[ 2 * range + 1 ] ;
530 for(
unsigned int n = 0 ; n < 2 * range + 1 ; n++)
533 convolution = list_query_pixels[n].
convolution(I, me) ;
540 likelihood[n] = fabs(convolution +
convlt );
541 if (likelihood[n]> threshold)
543 contraste = convolution /
convlt;
544 if((contraste > contraste_min) && (contraste < contraste_max) && fabs(1-contraste) < diff)
546 diff = fabs(1-contraste);
548 max = likelihood[n] ;
558 likelihood[n] = fabs(2*convolution) ;
559 if (likelihood[n] > max && likelihood[n] > threshold)
562 max = likelihood[n] ;
580 ip.
set_i( list_query_pixels[max_rank].i );
581 ip.
set_j( list_query_pixels[max_rank].j );
585 *
this = list_query_pixels[max_rank] ;
591 delete []list_query_pixels ;
598 ip.
set_i( list_query_pixels[0].i );
599 ip.
set_j( list_query_pixels[0].j );
604 if(std::fabs(contraste) > std::numeric_limits<double>::epsilon())
609 delete []list_query_pixels ;
616 return((m.
i != i) || (m.
j != j)) ;
622 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
623 return (os <<
"Alpha: " << vpMeS.
alpha
624 <<
" Convolution: " << vpMeS.
convlt
626 <<
" Weight: " << vpMeS.
weight );
629 return (os <<
"Alpha: " << vpMeS.
alpha
630 <<
" Convolution: " << vpMeS.
convlt
631 <<
" Weight: " << vpMeS.
weight );
void set_j(const double j)
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'...
void set_i(const double i)
Contains predetermined masks for sites and holds moving edges tracking parameters.
static const vpColor green
static int round(const double x)
double getThreshold() const
unsigned int getAngleStep() const
static const vpColor cyan
static double sqr(double x)
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
void setDisplay(vpMeSiteDisplayType select)
vpMeSite * getQueryList(const vpImage< unsigned char > &I, const int range)
VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpImagePoint &ip)
vp_deprecated void getSign(const vpImage< unsigned char > &I, const int range)
vpMatrix * getMask() const
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)
virtual void displayPoint(const vpImagePoint &ip, const vpColor &color)=0
static const vpColor blue