summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgaillaro2004-05-11 17:59:02 +0000
committergaillaro2004-05-11 17:59:02 +0000
commit0d23e95e643ffffd7e2f3788449c34de200e9ff9 (patch)
tree084339a25c52ab5b0272792575dc3e0ba24921fd
parentc77a00932d216b54f85a43eba8c4b6037b2470d6 (diff)
precision degressif
optimisation findcolorNN debut de poteaux
-rw-r--r--2004/i/nono/src/ovision/Makefile.defs5
-rw-r--r--2004/i/nono/src/ovision/adjust.cc2
-rw-r--r--2004/i/nono/src/ovision/comm.cc33
-rw-r--r--2004/i/nono/src/ovision/comm.h6
-rw-r--r--2004/i/nono/src/ovision/group.cc77
-rw-r--r--2004/i/nono/src/ovision/group.h64
-rw-r--r--2004/i/nono/src/ovision/segmNN.cc183
-rw-r--r--2004/i/nono/src/ovision/segmNN.h3
-rw-r--r--2004/i/nono/src/ovision/space.cc4
-rw-r--r--2004/i/nono/src/ovision/test_ovision.cc14
-rw-r--r--2004/i/nono/src/ovision/ui.cc7
11 files changed, 257 insertions, 141 deletions
diff --git a/2004/i/nono/src/ovision/Makefile.defs b/2004/i/nono/src/ovision/Makefile.defs
index 3aa21a9..9604038 100644
--- a/2004/i/nono/src/ovision/Makefile.defs
+++ b/2004/i/nono/src/ovision/Makefile.defs
@@ -1,10 +1,11 @@
-TARGETS += test_ovision testimg testmap
+TARGETS += test_ovision testimg testmap optim
LIBS += ovision.a
testimg_SOURCES = testimg.cc ovision.a video4linux.a
test_ovision_SOURCES = test_ovision.cc ovision.a image.a video4linux.a
testmap_SOURCES = testmap.cc ovision.a image.a video4linux.a
testdist_SOURCES = testdist.cc ovision.a
+optim_SOURCES = optim.cc ovision.a image.a
ovision_a_SOURCES = img.cc group.cc oconfig.cc map.cc segmNN.cc space.cc
testimg: $(testimg_SOURCES:%.cc=%.o)
@@ -15,5 +16,7 @@ testmap: $(testmap_SOURCES:%.cc=%.o)
testdist: $(testdist_SOURCES:%.cc=%.o)
+optim: $(optim_SOURCES:%.cc=%.o)
+
ovision.a: ${ovision_a_SOURCES:%.cc=ovision.a(%.o)}
diff --git a/2004/i/nono/src/ovision/adjust.cc b/2004/i/nono/src/ovision/adjust.cc
index fa0b448..3c84def 100644
--- a/2004/i/nono/src/ovision/adjust.cc
+++ b/2004/i/nono/src/ovision/adjust.cc
@@ -272,7 +272,7 @@ MouseFunc(int button, int state, int x, int y)
int i=0;
- cout << "Point ajoute: " << imgX << ", " << imgY << endl;
+ // cout << "Point ajoute: " << imgX << ", " << imgY << endl;
if (imgX >= 0)
{
diff --git a/2004/i/nono/src/ovision/comm.cc b/2004/i/nono/src/ovision/comm.cc
index 526b703..d81cf9c 100644
--- a/2004/i/nono/src/ovision/comm.cc
+++ b/2004/i/nono/src/ovision/comm.cc
@@ -47,8 +47,10 @@ Comm::Comm(char *filename)
// Ouverture de l'image pilote et stockage
img.LoadRGB(filename, 0, 360, 296);
+ imgLeft[0] = new unsigned char[img.nbPixels*3];
+ memcpy(imgLeft[0], img.tabData, sizeof(char) * img.nbPixels * 3);
//if (img.yuv) img.RGBtoYUV();
- tex[0] = LoadImage(img.width, img.height, img.tabData, tex[0]);
+ tex[0] = LoadImage(img.width, img.height, imgLeft[0], tex[0]);
// Conversion en YUV et stockage
img.LoadRGB(filename, 0, 360, 296);
@@ -72,6 +74,9 @@ Comm::Comm(char *filename)
// Affichage de l'image pilote en RGB et YUV
tex[1] = LoadImage(img.width, img.height, data[0], tex[1]);
tex[4] = LoadImage(img.width, img.height, data[1], tex[4]);
+
+ yuvSwitch = 0;
+ imgLeft[1] = NULL;
}
@@ -300,7 +305,7 @@ Comm::ExecuteUiCmds(char *buffer)
// Copie du nom de l'image courante
strcpy(fname, filename);
-
+
// Ouverture de l'image pilote et stockage
img.LoadRGB(filename, 0, 360, 296);
@@ -311,7 +316,10 @@ Comm::ExecuteUiCmds(char *buffer)
data[i] = new unsigned char[img.nbPixels*3];
}
- tex[0] = LoadImage(img.width, img.height, img.tabData, tex[0]);
+ delete[] imgLeft[0];
+ imgLeft[0] = new unsigned char[img.nbPixels*3];
+ memcpy(imgLeft[0], img.tabData, sizeof(char)*img.nbPixels*3);
+ tex[0] = LoadImage(img.width, img.height, imgLeft[0], tex[0]);
// Conversion en YUV et stockage
img.RGBtoYUV();
@@ -382,14 +390,19 @@ Comm::ExecuteUiCmds(char *buffer)
break;
case 'y':
- img.yuv = !img.yuv;
-
- // Conversion en YUV et stockage
- img.ReadRaw(fname);
- if (!img.yuv) img.YUVtoRGB();
- tex[3] = LoadImage(img.width, img.height, img.tabData, tex[3]);
- img.ReadRaw(fname);
+ yuvSwitch++;
+
+ cout << img.yuv << endl;
+ // Conversion en YUV et stockage
+ img.LoadRGB(fname, 0, 360, 296);
+ if (yuvSwitch%3 == 1) img.YUVtoRGB();
+ else if (yuvSwitch%3 == 2) img.RGBtoYUV();
+ delete[] imgLeft[1];
+ imgLeft[1] = new unsigned char[img.nbPixels*3];
+ memcpy(imgLeft[1], img.tabData, sizeof(char)*img.nbPixels*3);
+ tex[3] = LoadImage(img.width, img.height, imgLeft[1], tex[3]);
+ img.LoadRGB(fname, 0, 360, 296);
break;
case 'z':
diff --git a/2004/i/nono/src/ovision/comm.h b/2004/i/nono/src/ovision/comm.h
index f0a4ee4..c2e80c6 100644
--- a/2004/i/nono/src/ovision/comm.h
+++ b/2004/i/nono/src/ovision/comm.h
@@ -16,7 +16,11 @@
/// Interprete les commandes envoyes par l'interface UI et les executent
class Comm {
-
+
+ int yuvSwitch;
+ unsigned char *imgLeft[2];
+
+
public:
/// tableau des numeros de textures utilises par openGL
unsigned int tex[NBIMG];
diff --git a/2004/i/nono/src/ovision/group.cc b/2004/i/nono/src/ovision/group.cc
index 3b07e3b..5ffc246 100644
--- a/2004/i/nono/src/ovision/group.cc
+++ b/2004/i/nono/src/ovision/group.cc
@@ -35,6 +35,11 @@ Group::Group(Img *img, SegmNN *segm) {
/// Destructeur
Group::~Group() {
+}
+
+
+/// Supprime la liste des groupes
+void Group::FreeGroups () {
ZONE *pCur = zoneListBall;
ZONE *pPrev;
@@ -54,6 +59,25 @@ Group::~Group() {
free(pPrev);
}
+
+ zoneListBall = NULL;
+ zoneListGoal = NULL;
+}
+
+
+
+/// Construit la table des distances
+void Group::DoDeltaTable ()
+{
+
+}
+
+
+/// Retourne le delta utilisé pour la dissociation de 2 balles proches
+int Group::GetDelta (int y)
+{
+// return 50;
+ return (int)(20 + y*0.1);
}
@@ -70,11 +94,17 @@ void Group::Plague(int type, unsigned char numColor, int x, int y) {
// TODO ajouter une inertie ?
// Parcours de l'objet trouve de haut en bas
- 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)) {}
-
+ while ((xmax < img->width-1)&& (segm->FindColorNN(img->tabData + ((++xmax)+y* img->width)*3) == numColor)) {}
+ while ((xmin > 0) && (segm->FindColorNN(img->tabData + ((--xmin)+y* img->width)*3) == numColor)) {}
+ 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;
@@ -92,19 +122,23 @@ void Group::Plague(int type, unsigned char numColor, int x, int y) {
ZONE *pCur;
- if (type == BALL)
+ if (type == BALL)
+ {
pCur = zoneListBall;
+ }
else if (type == GOAL)
{
- if (!((pCur->ymin <= 0) && (pCur->ymax >= img->width)))
- return;
+// if (!((pCur->ymin <= 0) && (pCur->ymax >= img->width)))
+// return;
pCur = zoneListGoal;
}
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) <= PRECISION) && (abs(pCur->centery - centery) <= PRECISION)) {
+ if ((numColor == pCur->idColor) && (abs(pCur->centerx - centerx) <= GetDelta(imgY)) && (abs(pCur->centery - centery) <= GetDelta(imgY))) {
if (xmin < pCur->xmin) pCur->xmin = xmin;
if (xmax > pCur->xmax) pCur->xmax = xmax;
if (ymin < pCur->ymin) pCur->ymin = ymin;
@@ -155,9 +189,6 @@ void Group::Plague(int type, unsigned char numColor, int x, int y) {
if ((pLast->xmin <= 0) || (pLast->ymin <= 0) || (pLast->xmax >= img->width) || (pLast->ymax >= img->height))
pLast->partial = 1;
else pLast->partial = 0;
-
-
-
pLast->next = NULL;
}
@@ -185,21 +216,27 @@ void Group::ShowZones() {
/// Selectionne les points a tester dans l'image
/// @param numColor numero de la couleur a trouver
-void Group::JumpPoints(unsigned char numColor) {
+void Group::JumpPoints(unsigned char numColorBall, unsigned char numColorGoal) {
- zoneListBall = NULL;
- tabSegm = segm->tabSegm;
+ FreeGroups ();
// Initialisation de la couleur a chercher
- numColor = segm->index[numColor];
+ numColorBall = segm->index[numColorBall];
+ if (numColorGoal != 255)
+ numColorGoal = segm->index[numColorGoal];
+
+ int curColor;
// Parcours d'une partie des pixels de l'image
for (int x=0; x<img->width; x+=10) {
for (int y=0; y<img->height; y+=10) {
- if (tabSegm[y*img->width+x] == numColor)
- {
- Plague(BALL, numColor, x, y);
- }
+ // if (tabSegm[y*img->width+x] == numColor)
+
+ curColor = segm->FindColorNN(img->tabData + ((y*img->width+x) * 3));
+ if (curColor == numColorBall)
+ Plague(BALL, numColorBall, x, y);
+ else if (curColor == numColorGoal)
+ Plague(GOAL, numColorGoal, x, y);
}
}
diff --git a/2004/i/nono/src/ovision/group.h b/2004/i/nono/src/ovision/group.h
index 66d0207..c0bf594 100644
--- a/2004/i/nono/src/ovision/group.h
+++ b/2004/i/nono/src/ovision/group.h
@@ -36,50 +36,56 @@ struct ZONE {
/// Cree une liste chainee de zones correspondant aux balles
class Group {
- /// classe segmentation
- SegmNN *segm;
+ /// classe segmentation
+ SegmNN *segm;
- /// classe image
- Img *img;
+ /// classe image
+ Img *img;
- /// largeur de l'image a analyser
- int width;
+ /// largeur de l'image a analyser
+ int width;
+
+ /// longueur de l'image a analyser
+ int height;
- /// longueur de l'image a analyser
- int height;
-
public:
- /// pointeur vers l'image segmentee
- unsigned char *tabSegm;
+ /// pointeur vers l'image segmentee
+ unsigned char *tabSegm;
+
+ /// pointeur vers l'image RGB pour affichage
+ unsigned char *tabOut;
- /// pointeur vers l'image RGB pour affichage
- unsigned char *tabOut;
+ /// liste chainee pour sauver les zones des balles
+ ZONE *zoneListBall;
- /// liste chainee pour sauver les zones des balles
- ZONE *zoneListBall;
+ /// liste chainee pour sauver les zones des poteaux
+ ZONE *zoneListGoal;
- /// liste chainee pour sauver les zones des poteaux
- ZONE *zoneListGoal;
+ /// Constructeur
+ Group (Img *img, SegmNN *segm);
- /// Constructeur
- Group (Img *img, SegmNN *segm);
+ /// Destructeur
+ ~Group (void);
- /// Destructeur
- ~Group (void);
+ /// Selectionne les points a tester
+ void JumpPoints(unsigned char numColorBall, unsigned char numColorGoal = 255);
- /// Selectionne les points a tester
- void JumpPoints(unsigned char numColor);
+ /// Creation du tableau de RGB pour faire une image
+ void TabOut();
- /// Creation du tableau de RGB pour faire une image
- void TabOut();
+ /// Affiche les zones trouvees
+ void ShowZones();
- /// Affiche les zones trouvees
- void ShowZones();
+ void DoDeltaTable ();
+ /// Retourne le delta utilisé pour la dissociation de 2 balles proches
+ int GetDelta (int y);
protected:
- /// Cherche l'objet complet a partir d'un pixel
- void Plague(int type, unsigned char numColor, int x, int y);
+ /// Cherche l'objet complet a partir d'un pixel
+ void Plague(int type, unsigned char numColor, int x, int y);
+ /// Supprime la liste des groupes
+ void Group::FreeGroups ();
};
diff --git a/2004/i/nono/src/ovision/segmNN.cc b/2004/i/nono/src/ovision/segmNN.cc
index 9d24922..afc4bd1 100644
--- a/2004/i/nono/src/ovision/segmNN.cc
+++ b/2004/i/nono/src/ovision/segmNN.cc
@@ -31,12 +31,17 @@ SegmNN::SegmNN(Img *img, OConfig *config) {
/// Destructor SegmNN
SegmNN::~SegmNN()
{
+ delete [] node;
+ delete [] index;
+ delete [] freq;
+ delete [] tabSegm;
}
/// Affiche les poids du reseau de neurones (neural network : NN)
-void SegmNN::ShowNodes() {
-
+void
+SegmNN::ShowNodes()
+{
// Affichage des poids du NN
cout << "Poids:";
for(int i=0; i<nbOutput; i++)
@@ -49,17 +54,21 @@ void SegmNN::ShowNodes() {
/// @param nbOutput nombre de noeuds de la couche de sortie du NN
/// @param loadFromFile (GENERATE ou LOADFROMFILE) indique si les poids sont charges d'un fichier ou generes aleatoirement
-void SegmNN::BuildNN(int nbOutput, int loadFromFile) {
-
+void
+SegmNN::BuildNN(int nbOutput, int loadFromFile)
+{
SegmNN::nbOutput = nbOutput;
// Permet de charger les poids du NN depuis un fichier ou en les initialisant aleatoirement
- if (loadFromFile) {
+ if (loadFromFile)
+ {
// Verifie si le nombre de poids donne dans le fichier est suffisant
- if (config->nbNodeMax < nbOutput) {
+ if (config->nbNodeMax < nbOutput)
+ {
cerr << "SegmNN::BuildNN : Nombre de nodes insuffisants dans le fichier poids\n";
- }
- else {
+ }
+ else
+ {
// Charge les poids du NN et l'index des couleurs
delete [] node;
node = new unsigned char[nbOutput*3];
@@ -70,7 +79,7 @@ void SegmNN::BuildNN(int nbOutput, int loadFromFile) {
for (int i = 0; i<nbOutput; i++)
index[i] = config->index[i];
freq = new unsigned int[nbOutput];
- }
+ }
return;
}
@@ -86,23 +95,26 @@ void SegmNN::BuildNN(int nbOutput, int loadFromFile) {
freq = new unsigned int[nbOutput];
- for(int i=0; i<nbOutput; i++) {
+ for(int i=0; i<nbOutput; i++)
+ {
index[i] = i;
freq[i] = 0;
- for(int j=0; j<3; j++) {
+ for(int j=0; j<3; j++)
+ {
// Attribution aléatoire des poids
node[i*3+j] = (unsigned char) (255.0*rand()/(RAND_MAX+1.0));
if (node[i*3+j] < 30) node[i*3+j] = 30;
else if (node[i*3+j] > 220) node[i*3+j] = 220;
- }
- }
- cout << "oooooo\n";
+ }
+ }
}
/// Entraine un reseau de neurones
-void SegmNN::TrainNN() {
+void
+SegmNN::TrainNN()
+{
unsigned long pixelNum;
unsigned char *tabData;
@@ -113,58 +125,62 @@ void SegmNN::TrainNN() {
config->colorMode = img->hsi*2 + img->yuv;
config->groupColor = 0;
- for(long i=0; i<config->nn_nil; i++) {
+ for(long i=0; i<config->nn_nil; i++)
+ {
// On choisit un pixel au hasard
pixelNum = (unsigned long)(img->nbPixels*(rand()/(RAND_MAX+1.0)));
// Calcul des valeurs de sorties pour ce pixel
- for(int j=0; j<nbOutput; j++) {
+ for(int j=0; j<nbOutput; j++)
+ {
output[j] = 0;
- for(int k=0; k<3; k++) {
+ for(int k=0; k<3; k++)
+ {
if ((img->yuv && k==0) || (img->hsi && k==2))
output[j] += abs((int)(config->nn_influ_lum*node[j*3+k]-tabData[pixelNum*3+k])*abs(node[j*3+k]-tabData[pixelNum*3+k]));
else
output[j] += abs(node[j*3+k]-tabData[pixelNum*3+k])*abs(node[j*3+k]-tabData[pixelNum*3+k]);
- }
+ }
// On cherche la sortie ayant le plus haut niveau
- if (output[j] < output[numOutputMax]) {
+ if (output[j] < output[numOutputMax])
numOutputMax = j;
- }
- }
+ }
// Mis a jour des poids
- for(int k=0; k<3; k++) {
- node[numOutputMax*3+k] =
- (unsigned char)((node[numOutputMax*3+k] + config->nn_sl*tabData[pixelNum*3+k])/(1+config->nn_sl));
-
- // Recompense pour la sortie qui travaille
- freq[numOutputMax]++;
-
- // Verification des noeuds inutiles
- if ((i%300) == 299)
+ for(int k=0; k<3; k++)
{
- for (int k=0; k < nbOutput; k++)
+ node[numOutputMax*3+k] =
+ (unsigned char)((node[numOutputMax*3+k] + config->nn_sl*tabData[pixelNum*3+k])/(1+config->nn_sl));
+
+ // Recompense pour la sortie qui travaille
+ freq[numOutputMax]++;
+
+ // Verification des noeuds inutiles
+ if ((i%300) == 299)
{
- if (freq[numOutputMax] < config->nn_lazy_threshold)
+ for (int k=0; k < nbOutput; k++)
{
- // Regeneration de nouveaux poids
- for(int m=0; m<3; m++) {
- // Attribution aléatoire des poids
- node[numOutputMax*3+m] = (unsigned char) (255.0*rand()/(RAND_MAX+1.0));
- if (node[numOutputMax*3+m] < 30) node[numOutputMax*3+m] = 30;
- else if (node[numOutputMax*3+m] > 220) node[numOutputMax*3+m] = 220;
- }
+ if (freq[numOutputMax] < config->nn_lazy_threshold)
+ {
+ // Regeneration de nouveaux poids
+ for(int m=0; m<3; m++)
+ {
+ // Attribution aléatoire des poids
+ node[numOutputMax*3+m] = (unsigned char) (255.0*rand()/(RAND_MAX+1.0));
+ if (node[numOutputMax*3+m] < 30) node[numOutputMax*3+m] = 30;
+ else if (node[numOutputMax*3+m] > 220) node[numOutputMax*3+m] = 220;
+ }
+ }
+
+ // On remet le compteur a zero
+ freq[k] = 0;
}
- // On remet le compteur a zero
- freq[k] = 0;
}
}
-
- }
}
}
@@ -172,27 +188,43 @@ void SegmNN::TrainNN() {
/// Renvoie le code de la couleur segmentee
/// @param *x pointeur vers un tableau contenant une valeur RGB
-unsigned char SegmNN::FindColorNN(unsigned char *x) {
-
+unsigned char
+SegmNN::FindColorNN(unsigned char *x)
+{
int numOutputMax=0;
int output[nbOutput];
- int j;
+ int j,tmp;
// Calcul des valeurs de sorties pour ce pixel
- for(j=0; j<nbOutput; j++) {
- output[j] = 0;
-
- for(int k=0; k<3; k++) {
- if ((img->yuv && k==0) || (img->hsi && k==2))
- output[j] += abs((int)(config->nn_influ_lum*node[j*3+k]-x[k])*abs(node[j*3+k]-x[k]));
- else
- output[j] += abs(node[j*3+k]-x[k])*abs(node[j*3+k]-x[k]);
- }
+ if (img->yuv)
+ {
+ for(j=0; j<nbOutput; j++)
+ {
+ // XXX Ne pas oublier de mettre abs si on ne calcule pas les carrés
+ tmp = node[j*3]-x[0];
+ output[j] = abs((int)(config->nn_influ_lum*tmp*tmp));
+ tmp = node[j*3+1]-x[1];
+ output[j] += tmp*tmp;
+ tmp = node[j*3+2]-x[2];
+ output[j] += tmp*tmp;
+
+ // On selectionne la sortie ayant la plus grande valeur comme couleur
+ if (output[numOutputMax] > output[j])
+ numOutputMax = j;
+ }
+ }
+ else {
+ for(j=0; j<nbOutput; j++)
+ {
+ output[j] = 0;
- // On selectionne la sortie ayant la plus grande valeur comme couleur
- if (output[numOutputMax] > output[j]) {
- numOutputMax = j;
- }
+ for(int k=0; k<3; k++)
+ output[j] += abs(node[j*3+k]-x[k])*abs(node[j*3+k]-x[k]);
+
+ // On selectionne la sortie ayant la plus grande valeur comme couleur
+ if (output[numOutputMax] > output[j])
+ numOutputMax = j;
+ }
}
return numOutputMax;
@@ -200,7 +232,8 @@ unsigned char SegmNN::FindColorNN(unsigned char *x) {
/// Segmente l'image avec le reseau de neurones
-void SegmNN::Segm() {
+void SegmNN::Segm()
+{
unsigned char* tabData = img->tabData;
@@ -209,29 +242,45 @@ void SegmNN::Segm() {
// Parcours de l'image pour la segmentation
// On recupere l'index et non le numero de sortie du NN
- for (unsigned long i=0; i<img->nbPixels; i++) {
+ for (unsigned long i=0; i<img->nbPixels; i++)
+ {
tabSegm[i] = index[FindColorNN(tabData+i*3)];
- }
+ }
}
/// Segmente l'image pour une seule couleur uniquement et permet donc d'isoler un ficher
/// @param numColor numero de la couleur a isoler
-void SegmNN::Segm(int numColor) {
+void
+SegmNN::Segm(int numColor)
+{
unsigned char* tabData = img->tabData;
if (tabSegm) delete [] tabSegm;
tabSegm = new unsigned char[img->nbPixels];
// Parcours de l'image pour la segmentation
- for (unsigned long i=0; i<img->nbPixels; i++) {
+ for (unsigned long i=0; i<img->nbPixels; i++)
+ {
if (FindColorNN(tabData+i*3) == numColor) tabSegm[i] = 1;
else tabSegm[i] = 0;
- }
+ }
}
+
+/*void
+SegmNN::InitCache ()
+{
+
+
+}
+*/
+
+
/// Entraine plusieurs reseaux de neurones avec des parametres differents et crees les images associees
-void SegmNN::TestNN() {
+void
+SegmNN::TestNN()
+{
/* double sl[] = {0.01, 0.1, 1};
unsigned long nil[] = {100, 1000, 10000, 100000, 1000000};
diff --git a/2004/i/nono/src/ovision/segmNN.h b/2004/i/nono/src/ovision/segmNN.h
index 71ff6e6..d98c92f 100644
--- a/2004/i/nono/src/ovision/segmNN.h
+++ b/2004/i/nono/src/ovision/segmNN.h
@@ -65,9 +65,10 @@ class SegmNN
/// Entraine plusieurs reseaux de neurones avec des parametres differents
void TestNN();
- protected:
/// Renvoie le code la couleur segmentee
unsigned char FindColorNN(unsigned char *x);
+
+ protected:
};
diff --git a/2004/i/nono/src/ovision/space.cc b/2004/i/nono/src/ovision/space.cc
index 82d237f..a9e232b 100644
--- a/2004/i/nono/src/ovision/space.cc
+++ b/2004/i/nono/src/ovision/space.cc
@@ -115,7 +115,7 @@ int Space::Setup()
aY = (double)Space::CaracteristicDeterminant(matrix, 0) / det;
bY = (double)Space::CaracteristicDeterminant(matrix, 1) / det;
cY = (double)Space::CaracteristicDeterminant(matrix, 2) / det;
- cout << "aY: " << aY << " bY: " << bY << "cY: " << cY << endl;
+ // cout << "aY: " << aY << " bY: " << bY << "cY: " << cY << endl;
}
else
{
@@ -128,7 +128,7 @@ int Space::Setup()
{
aX = (setupTab[2].distx - setupTab[0].distx * (double)setupTab[2].x / setupTab[0].x) / (setupTab[2].y * setupTab[2].x - setupTab[0].y * setupTab[2].x);
bX = setupTab[0].distx / setupTab[0].x - aX * setupTab[0].y;
- cout << "aX: " << aX << " bX: " << bX << endl;
+// cout << "aX: " << aX << " bX: " << bX << endl;
}
else
{
diff --git a/2004/i/nono/src/ovision/test_ovision.cc b/2004/i/nono/src/ovision/test_ovision.cc
index 90af585..3b0219b 100644
--- a/2004/i/nono/src/ovision/test_ovision.cc
+++ b/2004/i/nono/src/ovision/test_ovision.cc
@@ -19,9 +19,9 @@ main()
v4l.calibrate ();
Space space(img.width, img.height, &oconfig);
- space.AddSetupPoint (230, 16, 30, 300);
- space.AddSetupPoint (208, 168, 40, 600);
- space.AddSetupPoint (201, 230, 50, 900);
+ space.AddSetupPoint (356, 23, 300, 300);
+ space.AddSetupPoint (283, 171, 600, 600);
+ space.AddSetupPoint (253, 234, 1000, 900);
space.Setup ();
SegmNN segmNN(&img, &oconfig);
@@ -45,19 +45,19 @@ main()
img.load(v4l);
sprintf(filename, "test%i.rgb", i);
img.WriteRGB(filename);
- segmNN.Segm();
+// segmNN.Segm();
- group.JumpPoints(oconfig.groupColor);
+ group.JumpPoints(oconfig.groupColor, oconfig.goalColor);
group.ShowZones();
std::cout << "-------------\n" << std::endl;
if (group.zoneListBall)
{
int x,y;
double angle;
- x = group.zoneListBall->centerx - img.width/2;
+ x = group.zoneListBall->centerx;
y = img.height - group.zoneListBall->centery;
+ space.GetLoc(x, y, x, y);
std::cout << x << " " << y << std::endl;
- space.GetLoc(0, y, x, y);
std::cout << y << std::endl;
}
diff --git a/2004/i/nono/src/ovision/ui.cc b/2004/i/nono/src/ovision/ui.cc
index 11b0da7..7317803 100644
--- a/2004/i/nono/src/ovision/ui.cc
+++ b/2004/i/nono/src/ovision/ui.cc
@@ -113,8 +113,11 @@ UI::UI(char *filename)
init_pair(3, COLOR_GREEN, COLOR_BLACK);
init_pair(4, COLOR_CYAN, COLOR_BLACK);
- sprintf(buf, "n %s\n", filename);
- SendSignal(buf);
+ if (filename)
+ {
+ sprintf(buf, "n %s\n", filename);
+ SendSignal(buf);
+ }
}