summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/ovision/group.cc
diff options
context:
space:
mode:
Diffstat (limited to '2004/i/nono/src/ovision/group.cc')
-rw-r--r--2004/i/nono/src/ovision/group.cc92
1 files changed, 54 insertions, 38 deletions
diff --git a/2004/i/nono/src/ovision/group.cc b/2004/i/nono/src/ovision/group.cc
index 5ffc246..a3170db 100644
--- a/2004/i/nono/src/ovision/group.cc
+++ b/2004/i/nono/src/ovision/group.cc
@@ -11,9 +11,7 @@
#include <math.h>
using namespace std;
-#define BALL 1
-#define GOAL 2
-
+#define BORD 5
/// Constructeur
@@ -23,6 +21,7 @@ Group::Group(Img *img, SegmNN *segm) {
// Sauvegarde des pointeurs
Group::img = img;
Group::segm = segm;
+ oconfig = OConfig::GetInstance ();
width = img->width;
height = img->height;
@@ -74,13 +73,38 @@ void Group::DoDeltaTable ()
/// Retourne le delta utilisé pour la dissociation de 2 balles proches
-int Group::GetDelta (int y)
+int Group::GetDelta (int type, int y)
{
-// return 50;
- return (int)(20 + y*0.1);
+ // return 50;
+
+ if (type == BALL)
+ return (int)(25 + y*0.1);
+ else return 3*(int)(25 + y*0.1);
+}
+
+
+/// Test si la zone trouvé est valide
+bool Group::IsValidZone (int type, int xmin, int xmax, int ymin, int ymax) {
+
+
+ // test si la zone trouve un trop petite -> parasite
+ if ( (abs(xmin - xmax) < oconfig->minLengthZone) || (abs(ymin - ymax) < oconfig->minLengthZone) )
+ return 0;
+
+ if (type == BALL)
+ {
+ }
+ else if (type == GOAL)
+ {
+ // test si la zone trouve touche le haut de l'image
+ if (ymin > 0) return 0;
+ }
+
+ return 1;
}
+
/// Cherche l'objet complet a partir d'un pixel donne
/// @param numColor numero de la couleur a chercher
@@ -99,46 +123,29 @@ void Group::Plague(int type, unsigned char numColor, int x, int y) {
while ((ymax < img->height-1) && (segm->FindColorNN(img->tabData + (x+(++ymax)* img->width)*3) == numColor)) {}
while ((ymin > 0) && (segm->FindColorNN(img->tabData + (x+(--ymin)* img->width)*3) == numColor)) {}
-/*while ((xmax < img->width-1)&& (tabSegm[(++xmax)+y* img->width] == numColor)) {}
-while ((xmin > 0) && (tabSegm[(--xmin)+y* img->width] == numColor)) {}
-while ((ymax < img->height-1) && (tabSegm[x+(++ymax)* img->width] == numColor)) {}
-while ((ymin > 0) && (tabSegm[x+(--ymin)* img->width] == numColor)) {}
-*/
-
- // Verification la validite des entrees
-/* if ((xmin < 0) || (xmin > img->width))
- xmin = 0;
- if ((xmax > img->img->width) || (xmax < 0))
- xmax = img->width;
- if ((ymin < 0) || (ymin > height))
- ymin = 0;
- if ((ymax > img->height) || (ymax < 0))
- ymax = img->height;
-*/
- // Calcul du centre de l'image
- int centerx, centery;
- centerx = (xmax+xmin)/2;
- centery = (ymax+ymin)/2;
+ // test si la zone trouve est une zone valide
+ if (!IsValidZone (type, xmin, xmax, ymin, ymax))
+ return;
ZONE *pCur;
-
+
if (type == BALL)
- {
pCur = zoneListBall;
- }
else if (type == GOAL)
- {
-// if (!((pCur->ymin <= 0) && (pCur->ymax >= img->width)))
-// return;
pCur = zoneListGoal;
- }
+ // Calcul du centre de l'image
+ int centerx, centery;
+ centerx = (xmax+xmin)/2;
+ centery = (ymax+ymin)/2;
+
+
ZONE *pLast=NULL;
int imgY;
while (pCur) {
imgY = (pCur->centery + centery) / 2;
// si on a deja ce groupe on actualise les donnees du groupe
- if ((numColor == pCur->idColor) && (abs(pCur->centerx - centerx) <= GetDelta(imgY)) && (abs(pCur->centery - centery) <= GetDelta(imgY))) {
+ if ((numColor == pCur->idColor) && (abs(pCur->centerx - centerx) <= GetDelta(type, imgY)) && (abs(pCur->centery - centery) <= GetDelta(type, imgY))) {
if (xmin < pCur->xmin) pCur->xmin = xmin;
if (xmax > pCur->xmax) pCur->xmax = xmax;
if (ymin < pCur->ymin) pCur->ymin = ymin;
@@ -186,10 +193,19 @@ while ((ymin > 0) && (tabSegm[x+(--ymin)* img->width] == numColor)) {}
pLast->idColor = numColor;
// test si la balle est vu partiellement ou completement
- if ((pLast->xmin <= 0) || (pLast->ymin <= 0) || (pLast->xmax >= img->width) || (pLast->ymax >= img->height))
- pLast->partial = 1;
- else pLast->partial = 0;
-
+ if (pLast->ymax >= img->height - BORD)
+ {
+ pLast->bottom = 1;
+ if ((pLast->xmin <= 0) || (pLast->xmax >= img->width) || (pLast->ymin <= 0))
+ pLast->partial = 1;
+ else pLast->partial = 0;
+ }
+ else
+ {
+ pLast->bottom = 0;
+ pLast->partial = 0;
+ }
+
pLast->next = NULL;
}
}