summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see/ovision.cc
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/see/ovision.cc')
-rw-r--r--2005/i/robert/src/ovision/see/ovision.cc63
1 files changed, 42 insertions, 21 deletions
diff --git a/2005/i/robert/src/ovision/see/ovision.cc b/2005/i/robert/src/ovision/see/ovision.cc
index c66d64a..734a789 100644
--- a/2005/i/robert/src/ovision/see/ovision.cc
+++ b/2005/i/robert/src/ovision/see/ovision.cc
@@ -1,5 +1,7 @@
#include "ovision.hh"
#include <iostream>
+#include <fstream>
+#include <sstream>
/// Constructeur
OVision::OVision (bool useSocket)
@@ -23,36 +25,55 @@ OVision::~OVision ()
delete colorTab_;
}
-/// Iniialisatoin de toutes les classes
-void
-OVision::init (const Group::ZoneType aim)
+void
+OVision::readColorSkittle (ObjectColor &o)
{
- aim_ = aim;
- oconfig_ = new OConfig;
- // Initialisation des classes
- if (aim == Group::redSkittle)
+ if (aim_ == Group::redSkittle)
{
colorTab_ = new ColorTable ("../runtime/rc/colortableRed.z");
- oconfig_->nnInfluLum = 0.4;
- oconfig_->groupColor.clear ();
- ObjectColor tmp;
- tmp.label = "redSkittle";
- tmp.color = 3;
- tmp.type = aim;
- oconfig_->groupColor.push_back (tmp);
+ o.label = "redSkittle";
}
else
{
colorTab_ = new ColorTable ("../runtime/rc/colortableGreen.z");
- oconfig_->nnInfluLum = 0.4;
- ObjectColor tmp;
- oconfig_->groupColor.clear ();
- tmp.label = "greenSkittle";
- tmp.color = 0;
- tmp.type = aim;
- oconfig_->groupColor.push_back (tmp);
+ o.label = "greenSkittle";
+ std::cout << " color " << o.label << "\n";
}
+ o.type = aim_;
+ // reading color value
+ std::ifstream file ("../runtime/rc/poids");
+ if (!file.is_open ())
+ throw std::string ("<OVision::readColorSkittle> file poids not found\n");
+ o.color = -1;
+ static const int bufferSize = 50;
+ char buffer[bufferSize];
+ while (!file.eof ())
+ {
+ file.getline (buffer, bufferSize);
+ std::string line (buffer);
+ if (line.find (o.label) != std::string::npos)
+ {
+ std::istringstream ss (line);
+ ss >> line;
+ ss >> o.color;
+ break;
+ }
+ }
+ if (o.color == -1)
+ throw std::string ("<OVision::readColorSkittle> error in file poids\n");
+ oconfig_->groupColor.clear ();
+ oconfig_->groupColor.push_back (o);
+}
+/// Iniialisatoin de toutes les classes
+void
+OVision::init (const Group::ZoneType aim)
+{
+ aim_ = aim;
+ oconfig_ = new OConfig;
+ // Initialisation des classes
+ ObjectColor tmp;
+ readColorSkittle (tmp);
img_ = new Img;
// Initialisation caméra
v4l_ = new Video4Linux ("/dev/video", oconfig_->width, oconfig_->height,