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 ;
332 double j1, i1, j11, i11;
335 int number_of_points = 2000 ;
336 double incr = 2 * M_PI / number_of_points ;
377 else if (std::fabs(
alpha2 -
alpha1) < std::fabs(
alpha1) * std::numeric_limits<double>::epsilon())
388 vpMeEllipse::updateTheta()
392 for(std::list<vpMeSite>::iterator it=
list.begin(); it!=
list.end(); ++it){
397 computeTheta(theta, K, iP) ;
407 vpMeEllipse::suppressPoints()
410 std::list<vpMeSite>::iterator itList =
list.begin();
411 for(std::list<double>::iterator it=
angle.begin(); it!=
angle.end(); ){
415 itList =
list.erase(itList) ;
416 it =
angle.erase(it);
441 "Moving edges on ellipse tracking not initialized")) ;
466 for (
unsigned int i=0 ; i < 3 ; i++)
503 for (
unsigned int i=0 ; i < 3 ; i++)
551 vpMeEllipse::setExtremities()
553 double alphamin = +1e6;
554 double alphamax = -1e6;
561 std::list<double>::const_iterator itAngle =
angle.begin();
563 for(std::list<vpMeSite>::const_iterator itList=
list.begin(); itList!=
list.end(); ++itList){
565 double alpha = *itAngle;
566 if (alpha < alphamin)
573 if (alpha > alphamax)
595 vpMeEllipse::leastSquare()
604 unsigned int iter =0 ;
620 "Not enought moving edges to track the ellipse")) ;
627 for(std::list<vpMeSite>::const_iterator it=
list.begin(); it!=
list.end(); ++it){
633 A[k][2] = 2 * p_me.
ifloat ;
634 A[k][3] = 2 * p_me.
jfloat ;
651 r.setIteration(iter) ;
655 for (i=0 ; i < nos_1 ; i++)
664 for(std::list<vpMeSite>::iterator it=
list.begin(); it!=
list.end(); ++it){
677 for(i = 0; i < 5; i ++)
711 const unsigned int n=5 ;
714 for (
unsigned int k =0 ; k < n ; k++)
716 std::cout <<
"Click points "<< k+1 <<
"/" << n ;
717 std::cout <<
" on the ellipse in the trigonometric order" <<std::endl ;
721 std::cout << iP[k] << std::endl;
754 for (
unsigned int k =0 ; k < n ; k++)
758 A[k][2] = 2* iP[k].
get_i() ;
759 A[k][3] = 2* iP[k].
get_j() ;
800 unsigned int n = (
unsigned int)(iP.size());
809 for (
unsigned int k =0 ; k < n ; k++)
812 A[k][1] = 2* iP[k].get_i() * iP[k].get_j() ;
813 A[k][2] = 2* iP[k].get_i() ;
814 A[k][3] = 2* iP[k].get_j() ;
844 double low_alpha,
double high_alpha)
917 vpMeEllipse::computeMoments()
919 double tane = tan(-1/
e);
931 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
937 vpMeEllipse::computeAngle(
int ip1,
int jp1,
double &_alpha1,
938 int ip2,
int jp2,
double &_alpha2)
941 double j1, i1, j11, i11;
944 int number_of_points = 2000 ;
945 double incr = 2 * M_PI / number_of_points ;
990 vpMeEllipse::computeAngle(
int ip1,
int jp1,
int ip2,
int jp2)
994 computeAngle(ip1,jp1,a1, ip2, jp2,a2) ;
1000 unsigned *i,
unsigned *j)
1002 vpCDEBUG(1) <<
" begin vpMeEllipse::initTracking()"<<std::endl ;
1015 for (
unsigned int k =0 ; k < n ; k++)
1018 A[k][1] = 2* i[k] * j[k] ;
1027 std::cout << K << std::endl;
1036 for (
unsigned int k =0 ; k < n ; k++)
1052 std::cout << K << std::endl;
1082 #endif // Deprecated
1107 const double &A,
const double &B,
const double &E,
1108 const double & smallalpha,
const double &highalpha,
1109 const vpColor &color,
unsigned int thickness)
1115 j1 = j2 = i1 = i2 = 0 ;
1121 double k = smallalpha ;
1122 while (k+incr<highalpha)
1127 j2 = A *cos(k+incr) ;
1128 i2 = B *sin(k+incr) ;
1133 iP11.
set_j ( center.
get_j() + cos(E) *j1 - sin(E) *i1 );
1134 iP11.
set_i ( center.
get_i() -( sin(E) *j1 + cos(E) *i1) );
1136 iP22.
set_j ( center.
get_j() + cos(E) *j2 - sin(E) *i2 );
1137 iP22.
set_i ( center.
get_i() -( sin(E) *j2 + cos(E) *i2) );
1144 j1 = A *cos(smallalpha) ;
1145 i1 = B *sin(smallalpha) ;
1147 j2 = A *cos(highalpha) ;
1148 i2 = B *sin(highalpha) ;
1153 iP11.
set_j ( center.
get_j() + cos(E) *j1 - sin(E) *i1 );
1154 iP11.
set_i ( center.
get_i() -( sin(E) *j1 + cos(E) *i1) );
1156 iP22.
set_j ( center.
get_j() + cos(E) *j2 - sin(E) *i2 );
1157 iP22.
set_i ( center.
get_i() -( sin(E) *j2 + cos(E) *i2) );
1186 const double &A,
const double &B,
const double &E,
1187 const double & smallalpha,
const double &highalpha,
1188 const vpColor &color,
unsigned int thickness)
1194 j1 = j2 = i1 = i2 = 0 ;
1200 double k = smallalpha ;
1201 while (k+incr<highalpha)
1206 j2 = A *cos(k+incr) ;
1207 i2 = B *sin(k+incr) ;
1212 iP11.
set_j ( center.
get_j() + cos(E) *j1 - sin(E) *i1 );
1213 iP11.
set_i ( center.
get_i() -( sin(E) *j1 + cos(E) *i1) );
1215 iP22.
set_j ( center.
get_j() + cos(E) *j2 - sin(E) *i2 );
1216 iP22.
set_i ( center.
get_i() -( sin(E) *j2 + cos(E) *i2) );
1223 j1 = A *cos(smallalpha) ;
1224 i1 = B *sin(smallalpha) ;
1226 j2 = A *cos(highalpha) ;
1227 i2 = B *sin(highalpha) ;
1232 iP11.
set_j ( center.
get_j() + cos(E) *j1 - sin(E) *i1 );
1233 iP11.
set_i ( center.
get_i() -( sin(E) *j1 + cos(E) *i1) );
1235 iP22.
set_j ( center.
get_j() + cos(E) *j2 - sin(E) *i2 );
1236 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 .
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)
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
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)
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.
virtual bool getClick(bool blocking=true)=0
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
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