summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see/magnifier.cc
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/see/magnifier.cc')
-rw-r--r--2005/i/robert/src/ovision/see/magnifier.cc53
1 files changed, 45 insertions, 8 deletions
diff --git a/2005/i/robert/src/ovision/see/magnifier.cc b/2005/i/robert/src/ovision/see/magnifier.cc
index 5811328..b61b260 100644
--- a/2005/i/robert/src/ovision/see/magnifier.cc
+++ b/2005/i/robert/src/ovision/see/magnifier.cc
@@ -10,8 +10,8 @@
#include "skittle.hh"
/// Constructeur
-Magnifier::Magnifier (Img *img, Segm *segm, Group::ZoneType aim)
-: segm_ (segm), img_ (img), aim_ (aim)
+Magnifier::Magnifier (Img *img, Segm *segm, Eraser *eraser, Group::ZoneType aim)
+: segm_ (segm), img_ (img), eraser_ (eraser), aim_ (aim)
{
oconfig_ = OConfig::getInstance ();
itemList_ = new std::vector<Zone>[Group::nbZoneType];
@@ -66,10 +66,13 @@ Magnifier::analyse (std::vector<Zone> &zoneList)
Skittle *s = isSkittle (*iter);
if (s)
{
- showZone (*iter);
- s->show ();
- delete s;
- find = true;
+ iter->alone = !eraser_->isTooBig (*iter);
+ iter->small = eraser_->isTooSmall (*iter);
+ if (iter->partial) getPosOut (*iter);
+ showZone (*iter);
+ //s->show ();
+ delete s;
+ find = true;
}
}
return find;
@@ -77,6 +80,37 @@ Magnifier::analyse (std::vector<Zone> &zoneList)
return false;
}
+
+/// Renvoie la position d'une quille
+void
+Magnifier::getPosOut (Zone &zone)
+{
+ static const int widthDiv3 = img_->width_ / 3;
+ static const int width2Div3 = widthDiv3 * 2;
+ static const int heightDiv3 = img_->height_ / 3;
+ static const int height2Div3 = heightDiv3 * 2;
+
+ if (zone.centery < heightDiv3)
+ {
+ if (zone.centerx < widthDiv3) zone.posOut = Zone::northwest;
+ else if (zone.centerx < width2Div3) zone.posOut = Zone::north;
+ else zone.posOut = Zone::northeast;
+ }
+ else if (zone.centery < height2Div3)
+ {
+ if (zone.centerx < widthDiv3) zone.posOut = Zone::west;
+ else if (zone.centerx < width2Div3) zone.posOut = Zone::center;
+ else zone.posOut = Zone::east;
+ }
+ else
+ {
+ if (zone.centerx < widthDiv3) zone.posOut = Zone::southwest;
+ else if (zone.centerx < width2Div3) zone.posOut = Zone::south;
+ else zone.posOut = Zone::southeast;
+ }
+
+}
+
bool
Magnifier::scan ()
{
@@ -319,10 +353,13 @@ Magnifier::showZone (const Zone &z) const
{
std::cout << "------------------------------------------------------------------\n";
std::cout << "<Magnifier::showZone> position : " << z.xmin << ", " << z.xmax << ", " << z.ymin << ", " << z.ymax << "\n";
+ std::cout << "<Magnifier::showZone> area : " << z.area << "\n";
+ std::cout << "<Magnifier::showZone> small : " << z.small << "\n";
std::cout << "<Magnifier::showZone> alone : " << z.alone << "\n";
- std::cout << "<Magnifier::showZone> density: " << z.density << "\n";
- std::cout << "<Magnifier::showZone> circleUp: " << z.circleUp << "\n";
+// std::cout << "<Magnifier::showZone> density: " << z.density << "\n";
+// std::cout << "<Magnifier::showZone> circleUp: " << z.circleUp << "\n";
std::cout << "<Magnifier::showZone> ratio/vertical: " << z.ratio << " " << (z.vertical?"vertical":"") << "\n";
// std::cout << "<Magnifier::showZone> orientation : " << z.pcX_ << ", " << z.pcY_ << "\n";
std::cout << "<Magnifier::showZone> partial : " << z.partial << "\n";
+ std::cout << "<Magnifier::showZone> posOut : " << z.posOut << "\n";
}