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
233 list_query_pixels = NULL ;
235 unsigned int range_ =
static_cast<unsigned int>(range);
237 list_query_pixels =
new vpMeSite[2 * range_ + 1] ;
242 double salpha = sin(
alpha);
243 double calpha = cos(
alpha);
247 for(k = -range ; k <= range ; k++)
265 list_query_pixels[n] = pel ;
269 return(list_query_pixels) ;
272 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
288 double salpha = sin(
alpha);
289 double calpha = cos(
alpha);
311 unsigned int index_mask ;
312 int height_ =
static_cast<int>(I.
getHeight());
313 int width_ =
static_cast<int>(I.
getWidth());
317 half = (
static_cast<int>(msize) - 1) >> 1 ;
319 if(horsImage( i , j , half + me->
getStrip() , height_, width_))
327 double theta =
alpha+M_PI/2;
330 while (theta<0) theta += M_PI;
331 while (theta>M_PI) theta -= M_PI;
336 if(abs(thetadeg) == 180 )
341 index_mask = (
unsigned int)(thetadeg/(
double)me->
getAngleStep());
343 unsigned int i_ =
static_cast<unsigned int>(
i);
344 unsigned int j_ =
static_cast<unsigned int>(
j);
345 unsigned int half_ =
static_cast<unsigned int>(half);
347 unsigned int ihalf = i_-half_ ;
348 unsigned int jhalf = j_-half_ ;
349 unsigned int ihalfa ;
351 for(
unsigned int a = 0 ; a < msize ; a++ )
354 for(
unsigned int b = 0 ; b < msize ; b++ )
379 const bool test_contraste)
507 double convolution_ = 0 ;
508 double max_convolution = 0 ;
510 double contraste = 0;
517 unsigned int range = me->
getRange() ;
522 double contraste_max = 1 + me->
getMu2();
523 double contraste_min = 1 - me->
getMu1();
526 double *likelihood=
new double[ 2 * range + 1 ] ;
537 for(
unsigned int n = 0 ; n < 2 * range + 1 ; n++)
540 convolution_ = list_query_pixels[n].
convolution(I, me) ;
547 likelihood[n] = fabs(convolution_ +
convlt );
548 if (likelihood[n]> threshold)
550 contraste = convolution_ /
convlt;
551 if((contraste > contraste_min) && (contraste < contraste_max) && fabs(1-contraste) < diff)
553 diff = fabs(1-contraste);
554 max_convolution= convolution_;
555 max = likelihood[n] ;
565 likelihood[n] = fabs(2*convolution_) ;
566 if (likelihood[n] > max && likelihood[n] > threshold)
568 max_convolution= convolution_;
569 max = likelihood[n] ;
587 ip.
set_i( list_query_pixels[max_rank].i );
588 ip.
set_j( list_query_pixels[max_rank].j );
592 *
this = list_query_pixels[max_rank] ;
598 delete []list_query_pixels ;
605 ip.
set_i( list_query_pixels[0].i );
606 ip.
set_j( list_query_pixels[0].j );
611 if(std::fabs(contraste) > std::numeric_limits<double>::epsilon())
616 delete []list_query_pixels ;
623 return((m.
i != i) || (m.
j != j)) ;
629 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
630 return (os <<
"Alpha: " << vpMeS.
alpha
631 <<
" Convolution: " << vpMeS.
convlt
633 <<
" Weight: " << vpMeS.
weight );
635 return (os <<
"Alpha: " << vpMeS.
alpha
636 <<
" Convolution: " << vpMeS.
convlt
637 <<
" 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 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)
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)
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