40 #include <visp3/me/vpMeEllipse.h>
42 #include <visp3/me/vpMe.h>
43 #include <visp3/core/vpRobust.h>
44 #include <visp3/core/vpException.h>
45 #include <visp3/core/vpImagePoint.h>
46 #include <visp3/core/vpDebug.h>
64 double i = iP.
get_i();
65 double j = iP.
get_j();
67 double A = 2*i+2*K[1]*j + 2*K[2] ;
68 double B = 2*K[0]*j + 2*K[1]*i + 2*K[3];
72 while (theta > M_PI) { theta -= M_PI ; }
73 while (theta < 0) { theta += M_PI ; }
81 : K(), iPc(), a(0.), b(0.), e(0.), iP1(), iP2(), alpha1(0), alpha2(2*M_PI),
82 ce(0.), se(0.), angle(), m00(0.), mu11(0.), mu20(0.), mu02(0.),
83 m10(0.), m01(0.), m11(0.), m02(0.), m20(0.),
84 thresholdWeight(0.2), expecteddensity(0.)
102 :
vpMeTracker(meellipse), K(), iPc(), a(0.), b(0.), e(0.), iP1(), iP2(), alpha1(0), alpha2(2*M_PI),
103 ce(0.), se(0.), angle(), m00(0.), mu11(0.), mu20(0.), mu02(0.),
104 m10(0.), m01(0.), m11(0.), m02(0.), m20(0.),
105 thresholdWeight(0.2), expecteddensity(0.)
161 "Moving edges on ellipse tracking not initialized")) ;
168 if (std::fabs(
me->
getSampleStep()) <= std::numeric_limits<double>::epsilon())
170 std::cout <<
"In vpMeEllipse::sample: " ;
171 std::cout <<
"function called with sample step = 0" ;
210 computeTheta(theta, K, iP11) ;
253 "Moving edges on ellipse tracking not initialized")) ;
271 vpMeEllipse::getParameters()
274 for (
unsigned int i=0 ; i < 5 ; i++)
278 double d = k[2]*k[2] - k[0]*k[1];
280 iPc.
set_i( (k[1] * k[3] - k[2] * k[4]) / d );
281 iPc.
set_j( (k[0] * k[4] - k[2] * k[3]) / d );
285 if (std::fabs(k[2]) <= std::numeric_limits<double>::epsilon()) {
289 e = (k[1] - k[0] + sq) / (2.0*k[2]);
295 if(
e < 0.0)
e += M_PI ;
301 double a2 = num / (k[0] + k[1] + sq ) ;
302 double b2 = num / (k[0] + k[1] - sq ) ;
314 std::cout <<
"K" << std::endl ;
316 std::cout <<
iPc << std::endl ;
333 int number_of_points = 2000 ;
334 double incr = 2 * M_PI / number_of_points ;
345 double j1 =
a *sin(k) ;
346 double i1 =
b *cos(k) ;
375 else if (std::fabs(
alpha2 -
alpha1) < std::fabs(
alpha1) * std::numeric_limits<double>::epsilon())
386 vpMeEllipse::updateTheta()
390 for(std::list<vpMeSite>::iterator it=
list.begin(); it!=
list.end(); ++it){
395 computeTheta(theta, K, iP) ;
405 vpMeEllipse::suppressPoints()
408 std::list<vpMeSite>::iterator itList =
list.begin();
409 for(std::list<double>::iterator it=
angle.begin(); it!=
angle.end(); ){
413 itList =
list.erase(itList) ;
414 it =
angle.erase(it);
439 "Moving edges on ellipse tracking not initialized")) ;
464 for (
unsigned int i=0 ; i < 3 ; i++)
501 for (
unsigned int i=0 ; i < 3 ; i++)
549 vpMeEllipse::setExtremities()
551 double alphamin = +1e6;
552 double alphamax = -1e6;
559 std::list<double>::const_iterator itAngle =
angle.begin();
561 for(std::list<vpMeSite>::const_iterator itList=
list.begin(); itList!=
list.end(); ++itList){
563 double alpha = *itAngle;
564 if (alpha < alphamin)
571 if (alpha > alphamax)
593 vpMeEllipse::leastSquare()
602 unsigned int iter =0 ;
618 "Not enought moving edges to track the ellipse")) ;
625 for(std::list<vpMeSite>::const_iterator it=
list.begin(); it!=
list.end(); ++it){
631 A[k][2] = 2 * p_me.
ifloat ;
632 A[k][3] = 2 * p_me.
jfloat ;
649 r.setIteration(iter) ;
653 for (i=0 ; i < nos_1 ; i++)
662 for(std::list<vpMeSite>::iterator it=
list.begin(); it!=
list.end(); ++it){
675 for(i = 0; i < 5; i ++)
709 const unsigned int n=5 ;
712 for (
unsigned int k =0 ; k < n ; k++)
714 std::cout <<
"Click points "<< k+1 <<
"/" << n ;
715 std::cout <<
" on the ellipse in the trigonometric order" <<std::endl ;
719 std::cout << iP[k] << std::endl;
752 for (
unsigned int k =0 ; k < n ; k++)
756 A[k][2] = 2* iP[k].
get_i() ;
757 A[k][3] = 2* iP[k].
get_j() ;
798 unsigned int n = (
unsigned int)(iP.size());
807 for (
unsigned int k =0 ; k < n ; k++)
810 A[k][1] = 2* iP[k].get_i() * iP[k].get_j() ;
811 A[k][2] = 2* iP[k].get_i() ;
812 A[k][3] = 2* iP[k].get_j() ;
842 double low_alpha,
double high_alpha)
915 vpMeEllipse::computeMoments()
917 double tane = tan(-1/
e);
929 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
935 vpMeEllipse::computeAngle(
int ip1,
int jp1,
double &_alpha1,
936 int ip2,
int jp2,
double &_alpha2)
940 int number_of_points = 2000 ;
941 double incr = 2 * M_PI / number_of_points ;
949 double j1 =
a *cos(k) ;
950 double i1 = b *sin(k) ;
986 vpMeEllipse::computeAngle(
int ip1,
int jp1,
int ip2,
int jp2)
990 computeAngle(ip1,jp1,a1, ip2, jp2,a2) ;
996 unsigned *i,
unsigned *j)
998 vpCDEBUG(1) <<
" begin vpMeEllipse::initTracking()"<<std::endl ;
1011 for (
unsigned int k =0 ; k < n ; k++)
1014 A[k][1] = 2* i[k] * j[k] ;
1023 std::cout << K << std::endl;
1032 for (
unsigned int k =0 ; k < n ; k++)
1048 std::cout << K << std::endl;
1078 #endif // Deprecated
1103 const double &A,
const double &B,
const double &E,
1104 const double & smallalpha,
const double &highalpha,
1105 const vpColor &color,
unsigned int thickness)
1111 j1 = j2 = i1 = i2 = 0 ;
1117 double k = smallalpha ;
1118 while (k+incr<highalpha)
1123 j2 = A *cos(k+incr) ;
1124 i2 = B *sin(k+incr) ;
1129 iP11.
set_j ( center.
get_j() + cos(E) *j1 - sin(E) *i1 );
1130 iP11.
set_i ( center.
get_i() -( sin(E) *j1 + cos(E) *i1) );
1132 iP22.
set_j ( center.
get_j() + cos(E) *j2 - sin(E) *i2 );
1133 iP22.
set_i ( center.
get_i() -( sin(E) *j2 + cos(E) *i2) );
1140 j1 = A *cos(smallalpha) ;
1141 i1 = B *sin(smallalpha) ;
1143 j2 = A *cos(highalpha) ;
1144 i2 = B *sin(highalpha) ;
1149 iP11.
set_j ( center.
get_j() + cos(E) *j1 - sin(E) *i1 );
1150 iP11.
set_i ( center.
get_i() -( sin(E) *j1 + cos(E) *i1) );
1152 iP22.
set_j ( center.
get_j() + cos(E) *j2 - sin(E) *i2 );
1153 iP22.
set_i ( center.
get_i() -( sin(E) *j2 + cos(E) *i2) );
1182 const double &A,
const double &B,
const double &E,
1183 const double & smallalpha,
const double &highalpha,
1184 const vpColor &color,
unsigned int thickness)
1190 j1 = j2 = i1 = i2 = 0 ;
1196 double k = smallalpha ;
1197 while (k+incr<highalpha)
1202 j2 = A *cos(k+incr) ;
1203 i2 = B *sin(k+incr) ;
1208 iP11.
set_j ( center.
get_j() + cos(E) *j1 - sin(E) *i1 );
1209 iP11.
set_i ( center.
get_i() -( sin(E) *j1 + cos(E) *i1) );
1211 iP22.
set_j ( center.
get_j() + cos(E) *j2 - sin(E) *i2 );
1212 iP22.
set_i ( center.
get_i() -( sin(E) *j2 + cos(E) *i2) );
1219 j1 = A *cos(smallalpha) ;
1220 i1 = B *sin(smallalpha) ;
1222 j2 = A *cos(highalpha) ;
1223 i2 = B *sin(highalpha) ;
1228 iP11.
set_j ( center.
get_j() + cos(E) *j1 - sin(E) *i1 );
1229 iP11.
set_i ( center.
get_i() -( sin(E) *j1 + cos(E) *i1) );
1231 iP22.
set_j ( center.
get_j() + cos(E) *j2 - sin(E) *i2 );
1232 iP22.
set_i ( center.
get_i() -( sin(E) *j2 + cos(E) *i2) );
double a
is the semiminor axis of the ellipse.
unsigned int getRange() const
Implementation of a matrix and operations on matrices.
double expecteddensity
Expected number of me to track along the ellipse.
double e
is the angle made by the major axis and the i axis of the image frame .
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void initTracking(const vpImage< unsigned char > &I)
unsigned int getWidth() const
#define vpDEBUG_ENABLE(level)
unsigned int numberOfSignal()
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'...
double thresholdWeight
Threshold for the robust least square.
Class to define colors available for display functionnalities.
int outOfImage(int i, int j, int half, int rows, int cols)
vpImagePoint iP1
The coordinates of the point corresponding to the smallest angle. More things about the are given a...
error that can be emited by ViSP classes.
Class that tracks an ellipse moving edges.
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
static int round(const double x)
double b
is the semimajor axis of the ellipse.
double se
Value of sin(e).
void setMu1(const double &mu_1)
vpMeSiteState getState() const
void set_i(const double ii)
void track(const vpImage< unsigned char > &Im)
std::list< vpMeSite > list
vpImagePoint iP2
The coordinates of the point corresponding to the highest angle. More things about the are given at...
vpImagePoint iPc
The coordinates of the ellipse center.
double m11
Second order raw moments.
double alpha1
The smallest angle.
static double sqr(double x)
void setDisplay(vpMeSiteDisplayType select)
void display(const vpImage< unsigned char > &I, vpColor col)
void track(const vpImage< unsigned char > &I)
Track sampled pixels.
double mu11
Second order central moments.
double m10
First order raw moments.
Contains abstract elements for a Distance to Feature type feature.
void setState(const vpMeSiteState &flag)
static double rad(double deg)
std::list< double > angle
Stores the value of the angle for each vpMeSite.
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)
void setMu2(const double &mu_2)
Implementation of column vector and the associated operations.
void track(const vpImage< unsigned char > &im, const vpMe *me, const bool test_contraste=true)
vpMe * me
Moving edges initialisation parameters.
Contains an M-Estimator and various influence function.
void initTracking(const vpImage< unsigned char > &I)
unsigned int getHeight() const
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Compute the pseudo inverse of the matrix using the SVD.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
double alpha2
The highest angle.
void setRange(const unsigned int &r)
double getSampleStep() const
vpMeSite::vpMeSiteDisplayType selectDisplay
virtual void display(const vpImage< unsigned char > &I, vpColor col)=0
double ce
Value of cos(e).
void set_ij(const double ii, const double jj)
static const vpColor blue