42 #ifndef DOXYGEN_SHOULD_SKIP_THIS
44 #include <visp/vpMbtMeEllipse.h>
46 #include <visp/vpMe.h>
47 #include <visp/vpRobust.h>
48 #include <visp/vpTrackingException.h>
49 #include <visp/vpDebug.h>
50 #include <visp/vpImagePoint.h>
59 vpMbtMeEllipse::vpMbtMeEllipse()
60 : iPc(), a(0.), b(0.), e(0.),
61 ce(0.), se(0.), mu11(0.), mu20(0.), mu02(0.), thresholdWeight(0.), expecteddensity(0.)
68 vpMbtMeEllipse::vpMbtMeEllipse(
const vpMbtMeEllipse &meellipse)
69 :
vpMeTracker(meellipse), iPc(), a(0.), b(0.), e(0.),
70 ce(0.), se(0.), mu11(0.), mu20(0.), mu02(0.), thresholdWeight(0.), expecteddensity(0.)
80 mu11 = meellipse.mu11;
81 mu20 = meellipse.mu20;
82 mu02 = meellipse.mu02;
84 expecteddensity = meellipse.expecteddensity;
90 vpMbtMeEllipse::~vpMbtMeEllipse()
109 vpDERROR_TRACE(2,
"Tracking error: Moving edges not initialized");
111 "Moving edges not initialized")) ;
118 if (std::fabs(me->getSampleStep()) <= std::numeric_limits<double>::epsilon())
120 std::cout <<
"In vpMbtMeEllipse::sample: " ;
121 std::cout <<
"function called with sample step = 0" ;
132 double t = (a-b)/(a+b);
134 int nb_points_to_track = (int)(circumference / me->getSampleStep());
135 double incr = 2*M_PI/nb_points_to_track;
145 for (
int pt=0; pt < nb_points_to_track; pt++)
150 iP_j = iPc.get_j() + ce *j - se *i;
151 iP_i = iPc.get_i() + se *j + ce *i;
160 double theta = atan( (-mu02*iP_j + mu02*iPc.get_j() + mu11*iP_i - mu11*iPc.get_i())
161 / (mu20*iP_i - mu11*iP_j + mu11*iPc.get_j() - mu20*iPc.get_i()))
165 pix.
init((
int)iP_i, (
int)iP_j, theta) ;
198 vpDERROR_TRACE(2,
"Tracking error: Moving edges not initialized");
200 "Moving edges not initialized")) ;
203 unsigned int n = numberOfSignal() ;
204 if ((
double)n<0.9*expecteddensity){
216 vpMbtMeEllipse::updateTheta()
220 for(std::list<vpMeSite>::iterator it=list.begin(); it!=list.end(); ++it){
227 theta = atan( (-mu02*p_me.
jfloat + mu02*iPc.get_j() + mu11*p_me.
ifloat - mu11*iPc.get_i())
228 / (mu20*p_me.
ifloat - mu11*p_me.
jfloat + mu11*iPc.get_j() - mu20*iPc.get_i()))
240 vpMbtMeEllipse::suppressPoints()
243 for(std::list<vpMeSite>::iterator itList=list.begin(); itList!=list.end();){
246 itList = list.erase(itList);
269 double mu20_p,
double mu11_p,
double mu02_p)
276 if (std::fabs(mu11_p) > std::numeric_limits<double>::epsilon()) {
279 a = sqrt((mu20_p + mu02_p + val_p)/2);
280 b = sqrt((mu20_p + mu02_p - val_p)/2);
282 e = (mu02_p - mu20_p + val_p)/(2*mu11_p);
333 if (std::fabs(mu11_p) > std::numeric_limits<double>::epsilon()) {
336 a = sqrt((mu20_p + mu02_p + val_p)/2);
337 b = sqrt((mu20_p + mu02_p - val_p)/2);
339 e = (mu02_p - mu20_p + val_p)/(2*mu11_p);
359 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
static void displayEllipse(const vpImage< unsigned char > &I, const vpImagePoint ¢er, const double &coef1, const double &coef2, const double &coef3, bool use_centered_moments, const vpColor &color, unsigned int thickness=1)
unsigned int getWidth() const
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'...
Class to define colors available for display functionnalities.
error that can be emited by ViSP classes.
static int round(const double x)
vpMeSiteState getState() const
void set_i(const double ii)
Error that can be emited by the vpTracker class and its derivates.
static double sqr(double x)
void setDisplay(vpMeSiteDisplayType select)
void track(const vpImage< unsigned char > &I)
Track sampled pixels.
Contains abstract elements for a Distance to Feature type feature.
void setState(const vpMeSiteState &flag)
void set_j(const double jj)
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 ...