43 #include <visp/vpConfig.h>
44 #ifndef DOXYGEN_SHOULD_SKIP_THIS
53 #include <visp/vpMbtMeLine.h>
54 #include <visp/vpTrackingException.h>
55 #include <visp/vpRobust.h>
59 normalizeAngle(
double &delta)
61 while (delta > M_PI) { delta -= M_PI ; }
62 while (delta < -M_PI) { delta += M_PI ; }
78 vpMbtMeLine::~vpMbtMeLine()
98 vpCDEBUG(1) <<
" begin vpMeLine::initTracking()"<<std::endl ;
104 PExt[0].ifloat = (float)ip1.
get_i() ;
105 PExt[0].jfloat = (float)ip1.
get_j() ;
106 PExt[1].ifloat = (float)ip2.
get_i() ;
107 PExt[1].jfloat = (float)ip2.
get_j() ;
118 expecteddensity = d / (double)me->getSampleStep();
120 delta = - theta + M_PI/2.0;
121 normalizeAngle(delta);
133 vpCDEBUG(1) <<
" end vpMeLine::initTracking()"<<std::endl ;
151 if (std::fabs(me->getSampleStep()) <= std::numeric_limits<double>::epsilon())
155 "sample step = 0")) ;
159 double diffsi = PExt[0].ifloat-PExt[1].ifloat;
160 double diffsj = PExt[0].jfloat-PExt[1].jfloat;
165 n_sample = length_p/(double)me->getSampleStep();
167 double stepi = diffsi/(double)n_sample;
168 double stepj = diffsj/(double)n_sample;
171 double is = PExt[1].ifloat;
172 double js = PExt[1].jfloat;
187 pix.
init((
int)is, (
int)js, delta, 0, sign) ;
207 vpCDEBUG(1) <<
"end vpMeLine::sample() : ";
208 vpCDEBUG(1) << n_sample <<
" point inserted in the list " << std::endl ;
220 for(std::list<vpMeSite>::iterator it=list.begin(); it!=list.end(); ){
223 if (fabs(sin(theta)) > 0.9)
225 if ((s.
i < imin) ||(s.
i > imax))
231 else if (fabs(cos(theta)) > 0.9)
233 if ((s.
j < jmin) || (s.
j > jmax))
241 if ((s.
i < imin) ||(s.
i > imax) || (s.
j < jmin) || (s.
j > jmax) )
263 vpCDEBUG(1) <<
"begin vpMeLine::sample() : "<<std::endl ;
270 if (std::fabs(me->getSampleStep()) <= std::numeric_limits<double>::epsilon())
278 double diffsi = PExt[0].ifloat-PExt[1].ifloat;
279 double diffsj = PExt[0].jfloat-PExt[1].jfloat;
283 double di = diffsi/sqrt(s) ;
284 double dj = diffsj/sqrt(s) ;
286 double length_p = sqrt(s);
289 n_sample = length_p/(double)me->getSampleStep();
290 double sample = (double)me->getSampleStep();
293 P.
init((
int) PExt[0].ifloat, (
int)PExt[0].jfloat, delta_1, 0, sign) ;
296 unsigned int memory_range = me->getRange() ;
299 for (
int i=0 ; i < 3 ; i++)
305 if ((P.
i < imin) ||(P.
i > imax) || (P.
j < jmin) || (P.
j > jmax) )
310 if(!outOfImage(P.
i, P.
j, 5, rows, cols))
312 P.
track(I,me,
false) ;
324 P.
init((
int) PExt[1].ifloat, (
int)PExt[1].jfloat, delta_1, 0, sign) ;
326 for (
int i=0 ; i < 3 ; i++)
332 if ((P.
i < imin) ||(P.
i > imax) || (P.
j < jmin) || (P.
j > jmax) )
338 if(!outOfImage(P.
i, P.
j, 5, rows, cols))
340 P.
track(I,me,
false) ;
352 me->setRange(memory_range);
354 vpCDEBUG(1) <<
"end vpMeLine::sample() : " ;
355 vpCDEBUG(1) << n_sample <<
" point inserted in the list " << std::endl ;
373 unsigned int n = numberOfSignal() ;
374 double expecteddensity = d / (double)me->getSampleStep();
376 if ((
double)n<0.5*expecteddensity && n > 0)
378 double delta_new = delta;
407 unsigned int n = list.size();
408 expecteddensity = d / (double)me->getSampleStep();
410 if ((
double)n<0.5*expecteddensity && n > 0)
412 double delta_new = delta;
414 PExt[0].ifloat = (float)ip1.
get_i() ;
415 PExt[0].jfloat = (float)ip1.
get_j() ;
416 PExt[1].ifloat = (float)ip2.
get_i() ;
417 PExt[1].jfloat = (float)ip2.
get_j() ;
428 vpMbtMeLine::updateDelta()
435 if(std::fabs(std::fabs(theta) - M_PI) <=
vpMath::maximum(std::fabs(theta), (
double)M_PI)*std::numeric_limits<double>::epsilon() )
440 diff = fabs(theta - theta_1);
446 delta = - theta + M_PI/2.0;
447 normalizeAngle(delta);
449 for(std::list<vpMeSite>::iterator it=list.begin(); it!=list.end(); ++it){
546 vpMbtMeLine::setExtremities()
554 for(std::list<vpMeSite>::const_iterator it=list.begin(); it!=list.end(); ++it){
569 if ( ! list.empty() )
571 PExt[0].ifloat = imin ;
572 PExt[0].jfloat = jmin ;
573 PExt[1].ifloat = imax ;
574 PExt[1].jfloat = jmax ;
577 if (fabs(imin-imax) < 25)
579 for(std::list<vpMeSite>::const_iterator it=list.begin(); it!=list.end(); ++it){
596 PExt[0].ifloat = imin ;
597 PExt[0].jfloat = jmin ;
598 PExt[1].ifloat = imax ;
599 PExt[1].jfloat = jmax ;
614 vpMbtMeLine::bubbleSortI()
617 unsigned int nbElmt = list.size();
618 for (
unsigned int pass = 1; pass < nbElmt; pass++)
621 for (
unsigned int i=0; i < nbElmt-pass; i++)
641 vpMbtMeLine::bubbleSortJ()
644 unsigned int nbElmt = list.size();
645 for(
unsigned int pass=1; pass < nbElmt; pass++)
648 for (
unsigned int i=0; i < nbElmt-pass; i++)
666 vpImagePoint itest(PExt[0].ifloat+(PExt[1].ifloat-PExt[0].ifloat)/2, PExt[0].jfloat+(PExt[1].jfloat-PExt[0].jfloat)/2);
669 pix.
init(itest.get_i(), itest.get_j(), delta, 0, sign);
673 unsigned int range = me->
getRange();
681 for(
unsigned int n = 0 ; n < 2 * range + 1 ; n++)
685 delete [] list_query_pixels;
void set_j(const double j)
unsigned int getRange() const
unsigned int getWidth() const
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)
#define vpDEBUG_ENABLE(niv)
vpMeSiteState getState() const
static Type maximum(const Type &a, const Type &b)
static const vpColor orange
Error that can be emited by the vpTracker class and its derivates.
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)
void track(const vpImage< unsigned char > &I)
Track sampled pixels.
Contains abstract elements for a Distance to Feature type feature.
vpMeSite * getQueryList(const vpImage< unsigned char > &I, const int range)
void setState(const vpMeSiteState &flag)
void track(const vpImage< unsigned char > &im, const vpMe *me, const bool test_contraste=true)
void initTracking(const vpImage< unsigned char > &I)
unsigned int getHeight() const
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
static const vpColor blue