46 #include <visp3/me/vpMe.h>
47 #include <visp3/core/vpColVector.h>
48 #include <visp3/core/vpMath.h>
50 #ifndef DOXYGEN_SHOULD_SKIP_THIS
74 permute(Type & a, Type & b)
82 droite_cartesienne(point P, point Q)
88 PQ.c = Q.y*P.x - Q.x*P.y;
96 point_intersection(droite D1, droite D2)
101 det = (D1.a*D2.b - D2.a*D1.b);
102 I.x = (D2.c*D1.b - D1.c*D2.b)/det;
103 I.y = (D1.c*D2.a - D2.c*D1.a)/det;
110 double Xmin,
double Ymin,
double Xmax,
double Ymax)
125 permute(point &A, point &B)
140 clipping (point A, point B,
141 double Xmin,
double Ymin,
double Xmax,
double Ymax,
142 point & Ac , point & Bc )
145 D[0].a = 1; D[0].b = 0; D[0].c = -Xmin;
146 D[1].a = 1; D[1].b = 0; D[1].c = -Xmax;
147 D[2].a = 0; D[2].b = 1; D[2].c = -Ymin;
148 D[3].a = 0; D[3].b = 1; D[3].c = -Ymax;
156 AB = droite_cartesienne(A,B);
179 if((code_P[0] | code_P[1])==0000)
193 if((code_P[0] & code_P[1])!=0000)
203 if(code_P[0] != 0000)
206 for(i=0,bit_i=1; !(code_P[0] & bit_i); i++,bit_i<<=1){;}
211 for(i=0,bit_i=1; !(code_P[1] & bit_i); i++,bit_i<<=1){;}
214 P[n] = point_intersection(AB,D[i]);
220 recale(P[n], Xmin,Ymin,Xmax,Ymax);
231 S_relative(point P, point Q,
232 double Xmin,
double Ymin,
double Xmax,
double Ymax)
240 recale(P, Xmin,Ymin,Xmax,Ymax);
241 recale(Q, Xmin,Ymin,Xmax,Ymax);
244 if((std::fabs(P.x-Xmin) <=
vpMath::maximum(std::fabs(P.x),std::fabs(Xmin))*std::numeric_limits<double>::epsilon())
246 (std::fabs(Q.x-Xmax) <=
vpMath::maximum(std::fabs(Q.x),std::fabs(Xmax))*std::numeric_limits<double>::epsilon()))
247 return( fabs(Ymax+Ymin-P.y-Q.y) );
251 if( ( (std::fabs(P.y-Ymin) <=
vpMath::maximum(std::fabs(P.y),std::fabs(Ymin))*std::numeric_limits<double>::epsilon())
253 (std::fabs(Q.y-Ymax) <=
vpMath::maximum(std::fabs(Q.y),std::fabs(Ymax))*std::numeric_limits<double>::epsilon()) )
255 ( (std::fabs(Q.y-Ymin) <=
vpMath::maximum(std::fabs(Q.y),std::fabs(Ymin))*std::numeric_limits<double>::epsilon())
257 (std::fabs(P.y-Ymax) <=
vpMath::maximum(std::fabs(P.y),std::fabs(Ymax))*std::numeric_limits<double>::epsilon()) ) )
258 return( fabs(Xmax+Xmin-P.x-Q.x) );
261 if( std::fabs(P.x-Xmin) <=
vpMath::maximum(std::fabs(P.x),std::fabs(Xmin))*std::numeric_limits<double>::epsilon()
263 std::fabs(Q.y-Ymax) <=
vpMath::maximum(std::fabs(Q.y),std::fabs(Ymax))*std::numeric_limits<double>::epsilon() )
264 return( 1-(Ymax-P.y)*(Q.x-Xmin) );
266 if( std::fabs(P.x-Xmin) <=
vpMath::maximum(std::fabs(P.x),std::fabs(Xmin))*std::numeric_limits<double>::epsilon()
268 std::fabs(Q.y-Ymin) <=
vpMath::maximum(std::fabs(Q.y),std::fabs(Ymin))*std::numeric_limits<double>::epsilon() )
269 return( 1-(P.y-Ymin)*(Q.x-Xmin) );
271 if( std::fabs(P.y-Ymin) <=
vpMath::maximum(std::fabs(P.y),std::fabs(Ymin))*std::numeric_limits<double>::epsilon()
272 && std::fabs(Q.x-Xmax) <=
vpMath::maximum(std::fabs(Q.x),std::fabs(Xmax))*std::numeric_limits<double>::epsilon() )
273 return( 1-(Xmax-P.x)*(Q.y-Ymin) );
275 if( std::fabs(P.y-Ymax) <=
vpMath::maximum(std::fabs(P.y),std::fabs(Ymax))*std::numeric_limits<double>::epsilon()
276 && std::fabs(Q.x-Xmax) <=
vpMath::maximum(std::fabs(Q.x),std::fabs(Xmax))*std::numeric_limits<double>::epsilon())
277 return( 1-(Xmax-P.x)*(Ymax-Q.y) );
280 printf(
"utils_ecm: ERREUR dans S_relative (%f,%f) (%f,%f) %f %f %f %f\n",
281 P.x,P.y,Q.x,Q.y,Xmin,Ymin,Xmax,Ymax);
293 unsigned int i_theta,
296 moitie = ((double)n)/2.0;
301 unsigned int nb_theta = angle.
getRows() ;
303 for(i_theta=0; i_theta<nb_theta; i_theta++)
305 double theta = M_PI/180*angle[i_theta];
307 double cos_theta = cos(theta);
308 double sin_theta = sin(theta);
313 if( std::fabs(angle[i_theta]-90) <=
vpMath::maximum(std::fabs(angle[i_theta]), 90.)*std::numeric_limits<double>::epsilon() )
315 P1.x=0; P1.y=-(int)n;
320 double tan_theta = sin_theta/cos_theta;
321 P1.x=-(int)n; P1.y=tan_theta*(-(int)n);
322 Q1.x=n; Q1.y=tan_theta*n;
329 for(i=0,Y=-moitie+0.5 ; i<n ; i++,Y++)
331 for(j=0,X=-moitie+0.5 ; j<n ; j++,X++)
337 if( clipping(P1,Q1, X-0.5,Y-0.5,X+0.5,Y+0.5, P,Q) )
340 v=S_relative(P,Q, X-0.5,Y-0.5,X+0.5,Y+0.5);
373 unsigned int angle_pas ;
374 angle_pas = 180 /
n_mask ;
377 for (
unsigned int i = 0 ; k <
n_mask ; i += angle_pas)
390 std::cout<< std::endl ;
391 std::cout<<
"Moving edges settings " <<std::endl ;
392 std::cout<< std::endl ;
393 std::cout<<
" Size of the convolution masks...."<<
mask_size<<
"x"<<
mask_size<<
" pixels"<<std::endl ;
394 std::cout<<
" Number of masks.................."<<
n_mask<<
" "<<std::endl ;
395 std::cout<<
" Query range +/- J................"<<
range<<
" pixels "<<std::endl ;
396 std::cout<<
" Likelihood test ratio............"<<
threshold<<std::endl ;
397 std::cout<<
" Contrast tolerance +/-..........."<<
mu1 * 100<<
"% and "<<
mu2 * 100<<
"% "<<std::endl ;
398 std::cout<<
" Sample step......................"<<
sample_step<<
" pixels"<<std::endl ;
399 std::cout<<
" Strip............................"<<
strip<<
" pixels "<<std::endl ;
400 std::cout<<
" Min_Samplestep..................."<<
min_samplestep<<
" pixels "<<std::endl ;
404 : threshold(1500), mu1(0.5), mu2(0.5), min_samplestep(4), anglestep(1), mask_sign(0),
405 range(4), sample_step(10), ntotal_sample(0), points_to_track(500), mask_size(5),
406 n_mask(180), strip(2), mask(NULL)
416 : threshold(1500), mu1(0.5), mu2(0.5), min_samplestep(4), anglestep(1), mask_sign(0),
417 range(4), sample_step(10), ntotal_sample(0), points_to_track(500), mask_size(5),
418 n_mask(180), strip(2), mask(NULL)
449 #ifdef VISP_HAVE_CPP11_COMPATIBILITY
459 mu1 = std::move(me.mu1);
460 mu2 = std::move(me.mu2);
464 n_mask = std::move(me.n_mask);
466 range = std::move(me.range);
470 strip = std::move(me.strip);
Implementation of a matrix and operations on matrices.
const vpMe & operator=(const vpMe &me)
Copy operator.
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
void setMaskNumber(const unsigned int &a)
static bool equal(double x, double y, double s=0.001)
int ntotal_sample
Distance between sampled points (in pixels)
static int round(const double x)
static Type maximum(const Type &a, const Type &b)
unsigned int mask_size
convolution masks' size in pixels (masks are square),
void setMaskSize(const unsigned int &a)
vpMe()
Array of matrices defining the different masks (one for every angle step).
unsigned int getRows() const
Return the number of rows of the 2D array.
double min_samplestep
Contrast continuity parameter (right boundary)
unsigned int n_mask
the number of convolution masks available for tracking ; defines resolution.
Implementation of column vector and the associated operations.
double mu1
Likelihood ratio threshold.
double mu2
Contrast continuity parameter (left boundary)
static int() sign(double x)
double sample_step
Seek range - on both sides of the reference pixel.