summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see/group.cc
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/see/group.cc')
-rw-r--r--2005/i/robert/src/ovision/see/group.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/2005/i/robert/src/ovision/see/group.cc b/2005/i/robert/src/ovision/see/group.cc
index 0fd8670..eee05bb 100644
--- a/2005/i/robert/src/ovision/see/group.cc
+++ b/2005/i/robert/src/ovision/see/group.cc
@@ -1,4 +1,4 @@
-// group.cc - Classe G
+// group.cc - Classe Group
// robert - Programme du robot APBteam
// Copyright (C) 2005 Olivier Gaillard
@@ -30,7 +30,13 @@ Group::addZone (const int idColor, const int xmin, const int xmax, const int ymi
zone.ymin = ymin; zone.ymax = ymax;
zone.centerx = (xmax+xmin)/2;
zone.centery = (ymax+ymin)/2;
+ // XXX test avec l'aire ?
+ // test si la zone est assez grande
+ if (((xmax - xmin) < oconfig_->minLengthZone)
+ || ((ymax - ymin) < oconfig_->minLengthZone))
+ return;
zone.color = idColor;
+ zone.circleUp = false;
for (std::vector<ObjectColor>::iterator iter = oconfig_->groupColor.begin ();
iter != oconfig_->groupColor.end (); ++iter)
if (idColor == iter->color)
@@ -57,12 +63,13 @@ void Group::plague (const unsigned char numColor, const int x, const int y)
// TODO ajouter une inertie ?
- int tmpY = y*img_->width_;
+ int tmpY = img_->tabY_[y];
// Parcours de l'objet trouve de haut en bas et de gauche à droite
- while ((xmax < img_->width_-1)&& (segm_->giveColor(img_->tabData_ + ((++xmax)+tmpY)*3, true, true) == numColor)) {}
- while ((xmin > 0) && (segm_->giveColor(img_->tabData_ + ((--xmin)+tmpY)*3, true, true) == numColor)) {}
- while ((ymax < img_->height_-1) && (segm_->giveColor(img_->tabData_ + (x+(++ymax)* img_->width_)*3, true, true) == numColor)) {}
- while ((ymin > 0) && (segm_->giveColor(img_->tabData_ + (x+(--ymin)* img_->width_)*3, true, true) == numColor)) {}
+ const int j = 2;
+ while ((xmax < img_->width_-1)&& (segm_->giveColor(img_->tabData_ + ((xmax)+tmpY)*3, true, true) == numColor)) {xmax += j;}
+ while ((xmin > 0) && (segm_->giveColor(img_->tabData_ + ((xmin)+tmpY)*3, true, true) == numColor)) {xmin -= j;}
+ while ((ymax < img_->height_-1) && (segm_->giveColor(img_->tabData_ + (img_->tabY_[ymax] + x)*3, true, true) == numColor)) {ymax +=j;}
+ while ((ymin > 0) && (segm_->giveColor(img_->tabData_ + (img_->tabY_[ymin]+x)*3, true, true) == numColor)) {ymin -= j;}
// Ajout de la zone
addZone (numColor, xmin, xmax, ymin, ymax);