summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/see')
-rw-r--r--2005/i/robert/src/ovision/see/Makefile.defs4
-rw-r--r--2005/i/robert/src/ovision/see/img.hh4
-rw-r--r--2005/i/robert/src/ovision/see/magnifier.cc3
-rw-r--r--2005/i/robert/src/ovision/see/ovision.cc36
-rw-r--r--2005/i/robert/src/ovision/see/ovision.hh8
-rw-r--r--2005/i/robert/src/ovision/see/space.cc11
-rw-r--r--2005/i/robert/src/ovision/see/space.hh2
-rw-r--r--2005/i/robert/src/ovision/see/test_cam.cc6
-rw-r--r--2005/i/robert/src/ovision/see/test_ovision.cc9
9 files changed, 57 insertions, 26 deletions
diff --git a/2005/i/robert/src/ovision/see/Makefile.defs b/2005/i/robert/src/ovision/see/Makefile.defs
index 2f2b930..9bd7f33 100644
--- a/2005/i/robert/src/ovision/see/Makefile.defs
+++ b/2005/i/robert/src/ovision/see/Makefile.defs
@@ -9,8 +9,9 @@ n2ml_OBJECTS = n2ml.o oconfig.o img.o segm.o segmLearn.o $(image_OBJECTS) $(data
genct_OBJECTS = genct.o oconfig.o segm.o segmLearn.o colorTable.o -lz
test_hotelling_OBJECTS = test_hotelling.o hotelling.o oconfig.o
test_cam_OBJECTS = test_cam.o img.o imgInterface.o oconfig.o $(video4linux_OBJECTS) $(image_OBJECTS) $(utils_OBJECTS) $(data_OBJECTS) $(net_OBJECTS)
+test_cam_socket_OBJECTS = test_cam_socket.o img.o imgInterface.o oconfig.o $(video4linux_OBJECTS) $(image_OBJECTS) $(utils_OBJECTS) $(data_OBJECTS) $(net_OBJECTS)
test_segm_OBJECTS = test_segm.o img.o segm.o segmLearn.o oconfig.o imgInterface.o colorTable.o segmTable.o $(image_OBJECTS) $(data_OBJECTS) $(net_OBJECTS)
-test_ovision_OBJECTS = test_ovision.cc $(ovision_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(utils_OBJECTS) $(data_OBJECTS)
+test_ovision_OBJECTS = test_ovision.cc $(ovision_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(utils_OBJECTS) $(data_OBJECTS)
test_ovisionogl_OBJECTS = test_ovisionogl.o $(ovision_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) motor.o config.o serial.o $(data_OBJECTS) $(net_OBJECTS)
test_ovisiontracker_OBJECTS = test_ovisiontracker.o $(ovision_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) motor.o date.o serial.o utils.o logger.o config.o $(data_OBJECTS) $(net_OBJECTS)
test_map_OBJECTS = test_map.o $(ovision_OBJECTS) $(image_OBJECTS) $(data_OBJECTS) $(net_OBJECTS)
@@ -25,6 +26,7 @@ n2ml: $(n2ml_OBJECTS:%.o=%.o)
genct: $(genct_OBJECTS:%.o=%.o)
test_hotelling: $(test_hotelling_OBJECTS:%.o=%.o)
test_cam: $(test_cam_OBJECTS:%.o=%.o)
+test_cam_socket: $(test_cam_socket_OBJECTS:%.o=%.o)
test_segm: $(test_segm_OBJECTS:%.o=%.o)
test_group: $(test_group_OBJECTS:%.o=%.o)
test_magnifier: $(test_magnifier_OBJECTS:%.o=%.o)
diff --git a/2005/i/robert/src/ovision/see/img.hh b/2005/i/robert/src/ovision/see/img.hh
index 5033bbf..f88fecd 100644
--- a/2005/i/robert/src/ovision/see/img.hh
+++ b/2005/i/robert/src/ovision/see/img.hh
@@ -63,6 +63,10 @@ class Img
inline int minWithBorder (int n, int min) {return n > min ? n : min;}
/// Renvoie le maximum en fonction d'une bordure
inline int maxWithBorder (int n, int max) {return n < max ? n : max;}
+ /// Get data image buffer.
+ inline unsigned char * getBuffer (void) const { return tabData_; }
+ /// Get the size of the image (height * width * 3).
+ inline unsigned long size (void) const { return nbPixels_; }
private:
/// Crée le tableau Y
diff --git a/2005/i/robert/src/ovision/see/magnifier.cc b/2005/i/robert/src/ovision/see/magnifier.cc
index 8ac1eb4..f4ac2f1 100644
--- a/2005/i/robert/src/ovision/see/magnifier.cc
+++ b/2005/i/robert/src/ovision/see/magnifier.cc
@@ -43,6 +43,7 @@ Magnifier::~Magnifier (void)
bool
Magnifier::analyse (std::vector<Zone> &zoneList)
{
+ std::cout << zoneList.size () << std::endl;
// remise à zéro de toutes les listes
for (int i=0; i<Group::nbZoneType; ++i)
itemList_[i].clear ();
@@ -362,4 +363,4 @@ Magnifier::showZone (const Zone &z) const
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";
-
+}
diff --git a/2005/i/robert/src/ovision/see/ovision.cc b/2005/i/robert/src/ovision/see/ovision.cc
index 734a789..e16539a 100644
--- a/2005/i/robert/src/ovision/see/ovision.cc
+++ b/2005/i/robert/src/ovision/see/ovision.cc
@@ -81,8 +81,11 @@ OVision::init (const Group::ZoneType aim)
v4l_->calibrate ();
// Prendre une image pour que la taille de l'image soit configuré
img_->load (*v4l_);
- segm_ = new SegmTable (*colorTab_);
+// segm_ = new SegmTable (*colorTab_);
+// segm_->setMode (oconfig_->inputColor);
+ segm_ = new SegmLearn;
segm_->setMode (oconfig_->inputColor);
+ segm_->buildNN (oconfig_->nnNbColor, Segm::loadFromFile);
eraser_ = new Eraser (oconfig_->width, 10);
eraser_->init ();
group_ = new Group (img_, segm_, eraser_);
@@ -111,9 +114,10 @@ OVision::update ()
// Compteur du nombre d'image traité
step_++;
// Cherche les balles
- group_->jumpPoints (oconfig_->groupColor);
+ // group_->jumpPoints (oconfig_->groupColor);
+ //group_->jumpPoints (0);
// Analyse et tri la liste de zones trouvées
- mag_->analyse (group_->getZoneList ());
+ //mag_->analyse (group_->getZoneList ());
// Parcours la liste de balles trouvées
/* if (group_->zoneListBall)
{
@@ -123,23 +127,33 @@ OVision::update ()
space->GetLoc (x, y, x, y);
}
*/
+ // Création des groupes
+ Group group (img_, segm_, eraser_);
+ std::vector<Zone> list;
+ group.jumpPoints(oconfig_->groupColor);
+ mag_->analyse (group.getZoneList ());
+ std::vector<Zone> &l = mag_->getItemList (Group::greenSkittle);
+ for (std::vector<Zone>::iterator iter = l.begin ();
+ iter != l.end (); ++iter)
+ {
+ mag_->showZone (*iter);
+ }
+ std::ostringstream ss;
+ ss << "vis" << step_ << ".yuv";
+ std::string name = ss.str ();
+ img_->writeRaw (name.c_str ());
}
/// Affiche d'info sur l'update
void
-OVision::showInfo () const
+OVision::showInfo (const Zone &zone) const
{
- std::cout << "-----------------------------------------------------------------" << std::endl;
- std::cout << "image n°" << step_ << std::endl;
- // Info sur les zones trouvées
- mag_->showItems (aim_);
- std::cout << "-------------\n" << std::endl;
- std::cout << "-------------\n" << std::endl;
+ mag_->showZone (zone);
}
/// Renvoie la position de la quille dans le référentiel robot
void
-OVision::getLoc (Zone &zone, int &x, int &y, int &angle, int &dist)
+OVision::getLoc (Zone &zone, int &x, int &y, double &angle, int &dist)
{
space_->getRealLoc (zone, x, y, angle, dist);
}
diff --git a/2005/i/robert/src/ovision/see/ovision.hh b/2005/i/robert/src/ovision/see/ovision.hh
index 6d3b892..8ecc230 100644
--- a/2005/i/robert/src/ovision/see/ovision.hh
+++ b/2005/i/robert/src/ovision/see/ovision.hh
@@ -25,6 +25,7 @@
#include "oconfig.hh"
#include "segmTable.hh"
+#include "segmLearn.hh"
#include "group.hh"
#include "magnifier.hh"
#include "colorTable.hh"
@@ -40,7 +41,7 @@ class OVision
OConfig *oconfig_;
Img *img_;
ColorTable *colorTab_;
- SegmTable *segm_;
+ SegmLearn *segm_;
Eraser *eraser_;
Group *group_;
Magnifier *mag_;
@@ -66,15 +67,16 @@ class OVision
/// Envoie l'image par socket
void sendImg ();
/// Affiche d'info sur l'update
- void showInfo () const;
+ void showInfo (const Zone &zone) const;
/// Renvoie la liste des quilles
std::vector<Zone>& OVision::getSkittles () const;
/// Renvoie le pointeur sur Video4Linux
Video4Linux &getVideo4Linux () const;
/// Renvoie la position de la quille dans le référentiel robot
/// Donne l'angle du robot par rapport à la balle + distance
- void getLoc (Zone &zone, int &x, int &y, int &angle, int &dist);
+ void getLoc (Zone &zone, int &x, int &y, double &angle, int &dist);
void readColorSkittle (ObjectColor &o);
+
};
#endif // ovision_h
diff --git a/2005/i/robert/src/ovision/see/space.cc b/2005/i/robert/src/ovision/see/space.cc
index efba67b..4133830 100644
--- a/2005/i/robert/src/ovision/see/space.cc
+++ b/2005/i/robert/src/ovision/see/space.cc
@@ -163,7 +163,7 @@ Space::getPos (const double locX, const double locY, const double posRobotX, con
/// Give Real Location dist and angle
void
-Space::getRealLoc (Zone &zone, int &x, int &y, int &angle, int &dist)
+Space::getRealLoc (Zone &zone, int &x, int &y, double &angle, int &dist)
{
// we want a pcY positive to sub it to centery
double newPcX, newPcY;
@@ -180,10 +180,15 @@ Space::getRealLoc (Zone &zone, int &x, int &y, int &angle, int &dist)
// we are looking for the bottom of the object
int tmpX = (int)((zone.xmax - zone.centerx) * newPcX + zone.centerx);
int tmpY = (int)((zone.ymax - zone.centery) * newPcY + zone.centery);
- std::cout << "<Space::getRealLoc> : "<< tmpX << " " << tmpY << "\n";
int newX, newY;
getLoc (tmpX, tmpY, newX, newY);
- angle = (int)(atan ((double)newX / ((double)newY + 90)));
+ newY += 90;
+ angle = (atan ((double)newX / ((double)newY)));
+ // correction de la calibration a l'arrache
+ angle += .174;
+ newX = (int)(newX * cos (.174));
+ newY = (int)(newY * cos (.174));
x = newX; y = newY;
dist = (int)sqrt (y*y + x*x);
+ std::cout << "<Space::getRealLoc> : "<< x << " " << y << " " << dist << " " << angle*360.0f/3.1415f/2.0f << "\n";
}
diff --git a/2005/i/robert/src/ovision/see/space.hh b/2005/i/robert/src/ovision/see/space.hh
index 7e9f7e8..a55eaf1 100644
--- a/2005/i/robert/src/ovision/see/space.hh
+++ b/2005/i/robert/src/ovision/see/space.hh
@@ -57,7 +57,7 @@ class Space
void getPos (const double locX, const double locY, const double posRobotX,
const double posRobotY, const double angleRobot, double &posX, double &posY);
/// Give Real Location dist and angle
- void getRealLoc (Zone &zone, int &x, int &y, int &angle, int &dist);
+ void getRealLoc (Zone &zone, int &x, int &y, double &angle, int &dist);
/// Ajoute un point pour l'etalonnage
void addSetupPoint (const int x, const int y, const int distx, const int disty);
/// Chargement des points a partir d'un fichier
diff --git a/2005/i/robert/src/ovision/see/test_cam.cc b/2005/i/robert/src/ovision/see/test_cam.cc
index f7dd315..799cbd1 100644
--- a/2005/i/robert/src/ovision/see/test_cam.cc
+++ b/2005/i/robert/src/ovision/see/test_cam.cc
@@ -21,13 +21,13 @@ int main(int argc, char **argv)
{
// Initialisation des classes
Img img;
- OConfig config;
+ OConfig oconfig;
// Acquisition de l'image et sauvegarde
if (argv[1]) ;
else
{
- Image::PixelFormat pf = Image::yuv;
- Video4Linux vid ("/dev/video", pf);
+ Video4Linux vid ("/dev/video", oconfig.width, oconfig.height,
+ oconfig.inputColor, oconfig.brightness);
vid.calibrate ();
img.load (vid);
}
diff --git a/2005/i/robert/src/ovision/see/test_ovision.cc b/2005/i/robert/src/ovision/see/test_ovision.cc
index c86c37d..765df94 100644
--- a/2005/i/robert/src/ovision/see/test_ovision.cc
+++ b/2005/i/robert/src/ovision/see/test_ovision.cc
@@ -25,7 +25,8 @@ main(int argv, char **argc)
}
OVision ovision;
ovision.init (aim);
- int t = 50;
+
+ int t = 200;
while (t--)
{
// Prends une image
@@ -42,8 +43,10 @@ main(int argv, char **argc)
std::vector<Zone> &z = ovision.getSkittles ();
for (unsigned i=0; i < z.size (); ++i)
{
- int x, y, dist, angle;
- ovision.getLoc (z[i], x, y, dist, angle);
+ int x, y, dist;
+ double angle;
+// ovision.showInfo (z[i]);
+ ovision.getLoc (z[i], x, y, angle, dist);
}
usleep (500000);
}