Skip to content
Snippets Groups Projects
Commit 4c104780 authored by even's avatar even
Browse files

Tests restored and Scan lines standardized

parent d53b9414
No related branches found
No related tags found
No related merge requests found
...@@ -988,8 +988,9 @@ void BSDetectionWidget::alternateTest () ...@@ -988,8 +988,9 @@ void BSDetectionWidget::alternateTest ()
void BSDetectionWidget::performanceTest () void BSDetectionWidget::performanceTest ()
{ {
if (detector.isMultiSelection ()) if (p1.equals (p2))
{ {
// No stroke -> automatic
cout << "Automatic extraction test" << endl; cout << "Automatic extraction test" << endl;
clock_t start = clock (); clock_t start = clock ();
for (int i = 0; i < 100; i++) detector.detectAll (); for (int i = 0; i < 100; i++) detector.detectAll ();
...@@ -999,11 +1000,7 @@ void BSDetectionWidget::performanceTest () ...@@ -999,11 +1000,7 @@ void BSDetectionWidget::performanceTest ()
} }
else else
{ {
if (p1.equals (p2)) udef = true;
{
cout << "Stroke undefined" << endl;
return;
}
cout << "Run test" << endl; cout << "Run test" << endl;
clock_t start = clock (); clock_t start = clock ();
for (int i = 0; i < 1000; i++) detector.detect (p1, p2); for (int i = 0; i < 1000; i++) detector.detect (p1, p2);
...@@ -1018,11 +1015,7 @@ void BSDetectionWidget::localTest () ...@@ -1018,11 +1015,7 @@ void BSDetectionWidget::localTest ()
{ {
cout << "Run test" << endl; cout << "Run test" << endl;
/* udef = true;
p1 = Pt2i (212, 169);
p2 = Pt2i (232, 152);
*/
p1 = Pt2i (175, 40); p1 = Pt2i (175, 40);
p2 = Pt2i (246, 79); p2 = Pt2i (246, 79);
......
#include "pt2i.h" #include "pt2i.h"
#include <cmath> // #include <cmath>
Pt2i::Pt2i () Pt2i::Pt2i ()
...@@ -194,7 +194,7 @@ Pt2i *Pt2i::drawing (const Pt2i p, int *n) const ...@@ -194,7 +194,7 @@ Pt2i *Pt2i::drawing (const Pt2i p, int *n) const
{ {
*n = dx + 1; *n = dx + 1;
pts = new Pt2i[dx + 1]; pts = new Pt2i[dx + 1];
e = dx; e = dx - 1; // car le point limite est trace en dessous de la droite
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (x1 < x2) while (x1 < x2)
...@@ -216,7 +216,7 @@ Pt2i *Pt2i::drawing (const Pt2i p, int *n) const ...@@ -216,7 +216,7 @@ Pt2i *Pt2i::drawing (const Pt2i p, int *n) const
{ {
*n = dy + 1; *n = dy + 1;
pts = new Pt2i[dy + 1]; pts = new Pt2i[dy + 1];
e = dy; e = dy; // car le point limite est trace a droite de la droite
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (y1 < y2) while (y1 < y2)
...@@ -241,7 +241,7 @@ Pt2i *Pt2i::drawing (const Pt2i p, int *n) const ...@@ -241,7 +241,7 @@ Pt2i *Pt2i::drawing (const Pt2i p, int *n) const
{ {
*n = 1 + dx; *n = 1 + dx;
pts = new Pt2i[dx + 1]; pts = new Pt2i[dx + 1];
e = dx; e = dx - 1; // car le point limite est trace en dessous de la droite
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (x1 < x2) while (x1 < x2)
...@@ -263,18 +263,18 @@ Pt2i *Pt2i::drawing (const Pt2i p, int *n) const ...@@ -263,18 +263,18 @@ Pt2i *Pt2i::drawing (const Pt2i p, int *n) const
{ {
*n = 1 - dy; *n = 1 - dy;
pts = new Pt2i[1 - dy]; pts = new Pt2i[1 - dy];
e = dy; e = - dy; // car le point limite est trace a gauche de la droite
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (y1 > y2) while (y1 > y2)
{ {
pts[i++] = Pt2i (x1, y1); pts[i++] = Pt2i (x1, y1);
y1 --; y1 --;
e += dx; e -= dx;
if (e > 0) if (e < 0)
{ {
x1 ++; x1 ++;
e += dy; e -= dy;
} }
} }
pts[i] = Pt2i (x1, y1); pts[i] = Pt2i (x1, y1);
...@@ -310,7 +310,7 @@ void Pt2i::draw (vector<Pt2i> &line, Pt2i p) const ...@@ -310,7 +310,7 @@ void Pt2i::draw (vector<Pt2i> &line, Pt2i p) const
// Octant 1 // Octant 1
if (dx >= dy) if (dx >= dy)
{ {
e = dx; e = dx - 1; // car le point limite est trace en dessous de la droite
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (x1 < x2) while (x1 < x2)
...@@ -330,7 +330,7 @@ void Pt2i::draw (vector<Pt2i> &line, Pt2i p) const ...@@ -330,7 +330,7 @@ void Pt2i::draw (vector<Pt2i> &line, Pt2i p) const
// Octant 2 // Octant 2
else else
{ {
e = dy; e = dy; // car le point limite est trace a droite de la droite
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (y1 < y2) while (y1 < y2)
...@@ -353,7 +353,7 @@ void Pt2i::draw (vector<Pt2i> &line, Pt2i p) const ...@@ -353,7 +353,7 @@ void Pt2i::draw (vector<Pt2i> &line, Pt2i p) const
// Octant 8 // Octant 8
if (dx >= -dy) if (dx >= -dy)
{ {
e = dx; e = dx - 1; // car le point limite est trace en dessous de la droite
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (x1 < x2) while (x1 < x2)
...@@ -373,18 +373,18 @@ void Pt2i::draw (vector<Pt2i> &line, Pt2i p) const ...@@ -373,18 +373,18 @@ void Pt2i::draw (vector<Pt2i> &line, Pt2i p) const
// Octant 7 // Octant 7
else else
{ {
e = dy; e = - dy; // car le point limite est trace a gauche de la droite
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (y1 > y2) while (y1 > y2)
{ {
line.push_back (Pt2i (x1, y1)); line.push_back (Pt2i (x1, y1));
y1 --; y1 --;
e += dx; e -= dx;
if (e > 0) if (e < 0)
{ {
x1 ++; x1 ++;
e += dy; e -= dy;
} }
} }
line.push_back (Pt2i (x1, y1)); line.push_back (Pt2i (x1, y1));
...@@ -424,7 +424,8 @@ Pt2i *Pt2i::pathTo (Pt2i p, int *n) const ...@@ -424,7 +424,8 @@ Pt2i *Pt2i::pathTo (Pt2i p, int *n) const
{ {
*n = dx; *n = dx;
pts = new Pt2i[dx]; pts = new Pt2i[dx];
e = dx; e = dx - 1; // car le point limite est trace en dessous de la droite
if (delta < 0) e++; // .. au dessus
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (x1 < x2) while (x1 < x2)
...@@ -446,7 +447,8 @@ Pt2i *Pt2i::pathTo (Pt2i p, int *n) const ...@@ -446,7 +447,8 @@ Pt2i *Pt2i::pathTo (Pt2i p, int *n) const
{ {
*n = dy; *n = dy;
pts = new Pt2i[dy]; pts = new Pt2i[dy];
e = dy; e = dy; // car le point limite est trace a droite de la droite
if (delta < 0) e--; // .. a gauche
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (y1 < y2) while (y1 < y2)
...@@ -471,7 +473,8 @@ Pt2i *Pt2i::pathTo (Pt2i p, int *n) const ...@@ -471,7 +473,8 @@ Pt2i *Pt2i::pathTo (Pt2i p, int *n) const
{ {
*n = dx; *n = dx;
pts = new Pt2i[dx]; pts = new Pt2i[dx];
e = dx; e = dx - 1; // car le point limite est trace en dessous de la droite
if (delta < 0) e++; // .. au dessus
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (x1 < x2) while (x1 < x2)
...@@ -490,19 +493,20 @@ Pt2i *Pt2i::pathTo (Pt2i p, int *n) const ...@@ -490,19 +493,20 @@ Pt2i *Pt2i::pathTo (Pt2i p, int *n) const
// Octant 7 // Octant 7
else else
{ {
*n = dy; *n = -dy;
pts = new Pt2i[-dy]; pts = new Pt2i[-dy];
e = dy; e = - dy; // car le point limite est trace a gauche de la droite
if (delta < 0) e--; // .. a droite
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
while (y1 > y2) while (y1 > y2)
{ {
y1 --; y1 --;
e += dx; e -= dx;
if (e > 0) if (e < 0)
{ {
x1 ++; x1 ++;
e += dy; e -= dy;
pts[i++] = Pt2i (delta, -delta); pts[i++] = Pt2i (delta, -delta);
} }
else pts[i++] = Pt2i (0, -delta); else pts[i++] = Pt2i (0, -delta);
...@@ -515,33 +519,35 @@ Pt2i *Pt2i::pathTo (Pt2i p, int *n) const ...@@ -515,33 +519,35 @@ Pt2i *Pt2i::pathTo (Pt2i p, int *n) const
bool *Pt2i::stepsTo (Pt2i p, int *n) const bool *Pt2i::stepsTo (Pt2i p, int *n) const
{ {
bool negx = p.xp < xp;
bool negy = p.yp < yp;
int x2 = (xp > p.xp) ? xp - p.xp : p.xp - xp; int x2 = (xp > p.xp) ? xp - p.xp : p.xp - xp;
int y2 = (yp > p.yp) ? yp - p.yp : p.yp - yp; int y2 = (yp > p.yp) ? yp - p.yp : p.yp - yp;
int dx = x2, dy = y2; int dx = x2, dy = y2, e = 0;
if (y2 > x2) if (y2 > x2)
{ {
dx = y2; dx = y2;
dy = x2; dy = x2;
x2 = y2; x2 = y2;
if (negx == negy) e++;
} }
int e, x = 0, i = 0; else if (negx != negy) e++;
*n = x2; e += dx - 1;
bool *paliers = new bool[x2];
e = dx;
dx *= 2; dx *= 2;
dy *= 2; dy *= 2;
int x = 0;
*n = x2;
bool *paliers = new bool[x2];
while (x < x2) while (x < x2)
{ {
x ++;
e -= dy; e -= dy;
if (e < 0) if (e < 0)
{ {
e += dx; e += dx;
paliers[i++] = true; paliers[x++] = true;
} }
else paliers[i++] = false; else paliers[x++] = false;
} }
return (paliers); return (paliers);
} }
...@@ -571,7 +577,7 @@ vector<Pt2i> Pt2i::drawOrtho (const Pt2i p2, int offset) const ...@@ -571,7 +577,7 @@ vector<Pt2i> Pt2i::drawOrtho (const Pt2i p2, int offset) const
{ {
if (dx >= dy) // Octant 1 if (dx >= dy) // Octant 1
{ {
e = dx; e = dx - 1;
dx = dx * 2; dx = dx * 2;
dy = dy * 2; dy = dy * 2;
if (offset < 0) floors = (steps * dy - e) / dx; if (offset < 0) floors = (steps * dy - e) / dx;
...@@ -625,7 +631,7 @@ vector<Pt2i> Pt2i::drawOrtho (const Pt2i p2, int offset) const ...@@ -625,7 +631,7 @@ vector<Pt2i> Pt2i::drawOrtho (const Pt2i p2, int offset) const
{ {
if (dx >= -dy) // Octant 8 if (dx >= -dy) // Octant 8
{ {
e = dx; e = dx - 1;
dx = dx * 2; dx = dx * 2;
dy = dy * 2; dy = dy * 2;
if (offset < 0) floors = (e - 1 + steps * dy) / dx; if (offset < 0) floors = (e - 1 + steps * dy) / dx;
...@@ -681,7 +687,7 @@ vector<Pt2i> Pt2i::drawOrtho (const Pt2i p2, int offset) const ...@@ -681,7 +687,7 @@ vector<Pt2i> Pt2i::drawOrtho (const Pt2i p2, int offset) const
{ {
if (-dx >= dy) // Octant 4 if (-dx >= dy) // Octant 4
{ {
e = dx; e = dx - 1;
dx = dx * 2; dx = dx * 2;
dy = dy * 2; dy = dy * 2;
if (offset < 0) floors = - (steps * dy + e) / dx; if (offset < 0) floors = - (steps * dy + e) / dx;
...@@ -735,7 +741,7 @@ vector<Pt2i> Pt2i::drawOrtho (const Pt2i p2, int offset) const ...@@ -735,7 +741,7 @@ vector<Pt2i> Pt2i::drawOrtho (const Pt2i p2, int offset) const
{ {
if (dx <= dy) // Octant 5 if (dx <= dy) // Octant 5
{ {
e = dx; e = dx - 1;
dx = dx * 2; dx = dx * 2;
dy = dy * 2; dy = dy * 2;
if (offset < 0) floors = (steps * dy - e - 1) / dx; if (offset < 0) floors = (steps * dy - e - 1) / dx;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
\headsep -1.5cm \headsep -1.5cm
\oddsidemargin 0.5cm \oddsidemargin 0.5cm
\evensidemargin 0.5cm \evensidemargin 0.5cm
\textheight 27.0cm \textheight 27.5cm
\textwidth 15.0cm \textwidth 15.0cm
\footskip 1.5cm \footskip 1.5cm
\parindent 0.0cm \parindent 0.0cm
...@@ -85,6 +85,9 @@ w && Largeur de correlation \\ ...@@ -85,6 +85,9 @@ w && Largeur de correlation \\
t && Epaisseur de correlation \\ t && Epaisseur de correlation \\
r && Taux de correlation \\ r && Taux de correlation \\
$\wedge \vee$ && Parcours des bandes \\ $\wedge \vee$ && Parcours des bandes \\
\hline \hline
\multicolumn{3}{|l|}{Analyse de la d\'etection initiale :} \\
$< \wedge > \vee$ && D\'ecalage de l'observation \\
\hline \hline
\end{tabular} \end{tabular}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment