46 #include <visp3/core/vpColVector.h> 47 #include <visp3/core/vpMath.h> 48 #include <visp3/me/vpMe.h> 49 #ifndef DOXYGEN_SHOULD_SKIP_THIS 62 template <
class Type>
inline void permute(Type &a, Type &b)
69 static droite droite_cartesienne(point P, point Q)
75 PQ.c = Q.y * P.x - Q.x * P.y;
80 static point point_intersection(droite D1, droite D2)
85 det = (D1.a * D2.b - D2.a * D1.b);
86 I.x = (D2.c * D1.b - D1.c * D2.b) / det;
87 I.y = (D1.c * D2.a - D2.c * D1.a) / det;
92 static void recale(point &P,
double Xmin,
double Ymin,
double Xmax,
double Ymax)
105 static void permute(point &A, point &B)
118 static bool clipping(point A, point B,
double Xmin,
double Ymin,
double Xmax,
double Ymax, point &Ac,
142 AB = droite_cartesienne(A, B);
148 for (n = 0; n < 2; n++) {
163 if ((code_P[0] | code_P[1]) == 0000)
178 if ((code_P[0] & code_P[1]) != 0000)
187 if (code_P[0] != 0000) {
189 for (i = 0, bit_i = 1; !(code_P[0] & bit_i); i++, bit_i <<= 1) {
193 for (i = 0, bit_i = 1; !(code_P[1] & bit_i); i++, bit_i <<= 1) {
197 P[n] = point_intersection(AB, D[i]);
202 recale(P[n], Xmin, Ymin, Xmax, Ymax);
209 static double S_relative(point P, point Q,
double Xmin,
double Ymin,
double Xmax,
double Ymax)
215 recale(P, Xmin, Ymin, Xmax, Ymax);
216 recale(Q, Xmin, Ymin, Xmax, Ymax);
219 if ((std::fabs(P.x - Xmin) <=
220 vpMath::maximum(std::fabs(P.x), std::fabs(Xmin)) * std::numeric_limits<double>::epsilon()) &&
221 (std::fabs(Q.x - Xmax) <=
222 vpMath::maximum(std::fabs(Q.x), std::fabs(Xmax)) * std::numeric_limits<double>::epsilon()))
223 return (fabs(Ymax + Ymin - P.y - Q.y));
227 if (((std::fabs(P.y - Ymin) <=
228 vpMath::maximum(std::fabs(P.y), std::fabs(Ymin)) * std::numeric_limits<double>::epsilon()) &&
229 (std::fabs(Q.y - Ymax) <=
230 vpMath::maximum(std::fabs(Q.y), std::fabs(Ymax)) * std::numeric_limits<double>::epsilon())) ||
231 ((std::fabs(Q.y - Ymin) <=
232 vpMath::maximum(std::fabs(Q.y), std::fabs(Ymin)) * std::numeric_limits<double>::epsilon()) &&
233 (std::fabs(P.y - Ymax) <=
234 vpMath::maximum(std::fabs(P.y), std::fabs(Ymax)) * std::numeric_limits<double>::epsilon())))
235 return (fabs(Xmax + Xmin - P.x - Q.x));
238 if (std::fabs(P.x - Xmin) <=
239 vpMath::maximum(std::fabs(P.x), std::fabs(Xmin)) * std::numeric_limits<double>::epsilon() &&
240 std::fabs(Q.y - Ymax) <=
241 vpMath::maximum(std::fabs(Q.y), std::fabs(Ymax)) * std::numeric_limits<double>::epsilon())
242 return (1 - (Ymax - P.y) * (Q.x - Xmin));
244 if (std::fabs(P.x - Xmin) <=
245 vpMath::maximum(std::fabs(P.x), std::fabs(Xmin)) * std::numeric_limits<double>::epsilon() &&
246 std::fabs(Q.y - Ymin) <=
247 vpMath::maximum(std::fabs(Q.y), std::fabs(Ymin)) * std::numeric_limits<double>::epsilon())
248 return (1 - (P.y - Ymin) * (Q.x - Xmin));
250 if (std::fabs(P.y - Ymin) <=
251 vpMath::maximum(std::fabs(P.y), std::fabs(Ymin)) * std::numeric_limits<double>::epsilon() &&
252 std::fabs(Q.x - Xmax) <=
253 vpMath::maximum(std::fabs(Q.x), std::fabs(Xmax)) * std::numeric_limits<double>::epsilon())
254 return (1 - (Xmax - P.x) * (Q.y - Ymin));
256 if (std::fabs(P.y - Ymax) <=
257 vpMath::maximum(std::fabs(P.y), std::fabs(Ymax)) * std::numeric_limits<double>::epsilon() &&
258 std::fabs(Q.x - Xmax) <=
259 vpMath::maximum(std::fabs(Q.x), std::fabs(Xmax)) * std::numeric_limits<double>::epsilon())
260 return (1 - (Xmax - P.x) * (Ymax - Q.y));
262 printf(
"utils_ecm: ERREUR dans S_relative (%f,%f) (%f,%f) %f %f %f %f\n", P.x, P.y, Q.x, Q.y, Xmin, Ymin, Xmax, Ymax);
272 unsigned int i_theta,
275 moitie = ((double)n) / 2.0;
280 unsigned int nb_theta = angle.
getRows();
282 for (i_theta = 0; i_theta < nb_theta; i_theta++) {
283 double theta = M_PI / 180 * angle[i_theta];
285 double cos_theta = cos(theta);
286 double sin_theta = sin(theta);
291 if (std::fabs(angle[i_theta] - 90) <=
vpMath::maximum(std::fabs(angle[i_theta]), 90.) *
292 std::numeric_limits<double>::epsilon())
299 double tan_theta = sin_theta / cos_theta;
301 P1.y = tan_theta * (-(int)n);
303 Q1.y = tan_theta * n;
310 for (i = 0, Y = -moitie + 0.5; i < n; i++, Y++) {
311 for (j = 0, X = -moitie + 0.5; j < n; j++, X++) {
316 if (clipping(P1, Q1, X - 0.5, Y - 0.5, X + 0.5, Y + 0.5, P, Q)) {
318 v = S_relative(P, Q, X - 0.5, Y - 0.5, X + 0.5, Y + 0.5);
348 unsigned int angle_pas;
349 angle_pas = 180 / n_mask;
352 for (
unsigned int i = 0; k < n_mask; i += angle_pas)
355 calcul_masques(angle, mask_size, mask);
361 std::cout << std::endl;
362 std::cout <<
"Moving edges settings " << std::endl;
363 std::cout << std::endl;
364 std::cout <<
" Size of the convolution masks...." << mask_size <<
"x" << mask_size <<
" pixels" << std::endl;
365 std::cout <<
" Number of masks.................." << n_mask <<
" " << std::endl;
366 std::cout <<
" Query range +/- J................" << range <<
" pixels " << std::endl;
367 std::cout <<
" Likelihood test ratio............" << threshold << std::endl;
368 std::cout <<
" Contrast tolerance +/-..........." << mu1 * 100 <<
"% and " << mu2 * 100 <<
"% " << std::endl;
369 std::cout <<
" Sample step......................" << sample_step <<
" pixels" << std::endl;
370 std::cout <<
" Strip............................" << strip <<
" pixels " << std::endl;
371 std::cout <<
" Min_Samplestep..................." << min_samplestep <<
" pixels " << std::endl;
375 : threshold(1500), mu1(0.5), mu2(0.5), min_samplestep(4), anglestep(1), mask_sign(0), range(4), sample_step(10),
376 ntotal_sample(0), points_to_track(500), mask_size(5), n_mask(180), strip(2), mask(NULL)
417 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 426 mu1 = std::move(me.mu1);
427 mu2 = std::move(me.mu2);
431 n_mask = std::move(me.n_mask);
433 range = std::move(me.range);
437 strip = std::move(me.strip);
Implementation of a matrix and operations on matrices.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=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 Type maximum(const Type &a, const Type &b)
void setMaskSize(const unsigned int &a)
vpMe & operator=(const vpMe &me)
Copy operator.
unsigned int getRows() const
static int round(double x)
double min_samplestep
Contrast continuity parameter (right boundary)
Implementation of column vector and the associated operations.
double mu1
Likelihood ratio threshold.
double mu2
Contrast continuity parameter (left boundary)
double sample_step
Seek range - on both sides of the reference pixel.
static int() sign(double x)