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
103 : i(0), j(0), i_1(0), j_1(0), ifloat(0), jfloat(0), v(0), mask_sign(1), alpha(0.),
104 convlt(0.), normGradient(0), weight(1), selectDisplay(NONE), state(NO_SUPPRESSION)
105 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
112 : i(0), j(0), i_1(0), j_1(0), ifloat(0), jfloat(0), v(0), mask_sign(1), alpha(0.),
113 convlt(0.), normGradient(0), weight(1), selectDisplay(NONE), state(NO_SUPPRESSION)
114 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
128 : i(0), j(0), i_1(0), j_1(0), ifloat(0), jfloat(0), v(0), mask_sign(1), alpha(0.),
129 convlt(0.), normGradient(0), weight(1), selectDisplay(NONE), state(NO_SUPPRESSION)
130 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
143 selectDisplay =
NONE ;
162 selectDisplay =
NONE ;
179 selectDisplay =
NONE ;
207 selectDisplay = m.selectDisplay;
210 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
237 list_query_pixels = NULL ;
239 unsigned int range_ =
static_cast<unsigned int>(range);
241 list_query_pixels =
new vpMeSite[2 * range_ + 1] ;
246 double salpha = sin(
alpha);
247 double calpha = cos(
alpha);
251 for(k = -range ; k <= range ; k++)
269 list_query_pixels[n] = pel ;
273 return(list_query_pixels) ;
276 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
292 double salpha = sin(
alpha);
293 double calpha = cos(
alpha);
315 unsigned int index_mask ;
316 int height_ =
static_cast<int>(I.
getHeight());
317 int width_ =
static_cast<int>(I.
getWidth());
321 half = (
static_cast<int>(msize) - 1) >> 1 ;
323 if(horsImage( i , j , half + me->
getStrip() , height_, width_))
331 double theta =
alpha+M_PI/2;
334 while (theta<0) theta += M_PI;
335 while (theta>M_PI) theta -= M_PI;
340 if(abs(thetadeg) == 180 )
345 index_mask = (
unsigned int)(thetadeg/(
double)me->
getAngleStep());
347 unsigned int i_ =
static_cast<unsigned int>(
i);
348 unsigned int j_ =
static_cast<unsigned int>(
j);
349 unsigned int half_ =
static_cast<unsigned int>(half);
351 unsigned int ihalf = i_-half_ ;
352 unsigned int jhalf = j_-half_ ;
353 unsigned int ihalfa ;
355 for(
unsigned int a = 0 ; a < msize ; a++ )
358 for(
unsigned int b = 0 ; b < msize ; b++ )
383 const bool test_contraste)
511 double convolution_ = 0 ;
512 double max_convolution = 0 ;
514 double contraste = 0;
521 unsigned int range = me->
getRange() ;
526 double contraste_max = 1 + me->
getMu2();
527 double contraste_min = 1 - me->
getMu1();
530 double *likelihood=
new double[ 2 * range + 1 ] ;
541 for(
unsigned int n = 0 ; n < 2 * range + 1 ; n++)
544 convolution_ = list_query_pixels[n].
convolution(I, me) ;
551 likelihood[n] = fabs(convolution_ +
convlt );
552 if (likelihood[n]> threshold)
554 contraste = convolution_ /
convlt;
555 if((contraste > contraste_min) && (contraste < contraste_max) && fabs(1-contraste) < diff)
557 diff = fabs(1-contraste);
558 max_convolution= convolution_;
559 max = likelihood[n] ;
569 likelihood[n] = fabs(2*convolution_) ;
570 if (likelihood[n] > max && likelihood[n] > threshold)
572 max_convolution= convolution_;
573 max = likelihood[n] ;
591 ip.
set_i( list_query_pixels[max_rank].i );
592 ip.
set_j( list_query_pixels[max_rank].j );
596 *
this = list_query_pixels[max_rank] ;
602 delete []list_query_pixels ;
609 ip.
set_i( list_query_pixels[0].i );
610 ip.
set_j( list_query_pixels[0].j );
615 if(std::fabs(contraste) > std::numeric_limits<double>::epsilon())
620 delete []list_query_pixels ;
627 return((m.
i != i) || (m.
j != j)) ;
631 VISP_EXPORT std::ostream& operator<<(std::ostream& os,
vpMeSite& vpMeS)
633 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
634 return (os <<
"Alpha: " << vpMeS.
alpha
635 <<
" Convolution: " << vpMeS.
convlt
637 <<
" Weight: " << vpMeS.
weight );
639 return (os <<
"Alpha: " << vpMeS.
alpha
640 <<
" Convolution: " << vpMeS.
convlt
641 <<
" 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'...
Contains predetermined masks for sites and holds moving edges tracking parameters.
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)
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)
vp_deprecated void getSign(const vpImage< unsigned char > &I, const int range)
vpMatrix * getMask() const
void set_j(const double jj)
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