summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/ovision/oconfig.cc
diff options
context:
space:
mode:
Diffstat (limited to '2004/i/nono/src/ovision/oconfig.cc')
-rw-r--r--2004/i/nono/src/ovision/oconfig.cc220
1 files changed, 87 insertions, 133 deletions
diff --git a/2004/i/nono/src/ovision/oconfig.cc b/2004/i/nono/src/ovision/oconfig.cc
index f424159..98f8ad9 100644
--- a/2004/i/nono/src/ovision/oconfig.cc
+++ b/2004/i/nono/src/ovision/oconfig.cc
@@ -13,20 +13,44 @@ using namespace std;
OConfig *OConfig::instance = 0;
+
+/// Constructor
+/// @param *filename nom du fichier de config
+OConfig::OConfig(char *filename)
+{
+ instance = this;
+
+ Load (filename);
+
+ colorMode = 0;
+ color = NULL;
+ node = NULL;
+ index = NULL;
+ LoadNNFile("rc/poids");
+ LoadDistFile("rc/dist");
+}
+
+/// Destructor
+OConfig::~OConfig()
+{
+}
+
/// Parse une ligne du fichier de config
/// @param *var nom de la variable a fixer
/// @param *arg valeur de la variable
-void OConfig::Parse(char *var, char *arg) {
-
+void
+OConfig::Parse(char *var, char *arg)
+{
char argu[20];
-
+
if (!arg) cerr << "OConfig::Parse : Error during config file parsing" << endl;
strcpy(argu, arg);
-
+
// Verifie si l'argument est un nombre ou un nom de fichier
if (((argu[0]>'9') || (argu[0] < '0'))
- && strcmp(var, "Source") && strcmp(var, "imgPath")) {
+ && strcmp(var, "Source") && strcmp(var, "imgPath"))
+ {
FILE *file;
file=fopen(arg, "r");
@@ -35,55 +59,36 @@ void OConfig::Parse(char *var, char *arg) {
fgets(argu, 20,file);
fclose(file);
- }
+ }
// Affecte la valeur de argu a la variable var
- if (!strcmp(var, "Hauteur_Image")) height = atoi(argu);
- else if(!strcmp(var,"Largeur_Image")) width = atoi(argu);
- else if(!strcmp(var,"NN_Step_Learning")) nn_sl = atof(argu);
- else if(!strcmp(var,"NN_Neighborhood_Learning")) nn_nl = atof(argu);
- else if(!strcmp(var,"NN_Number_Iteration_Learning")) nn_nil = atol(argu);
- else if(!strcmp(var,"NN_Nombre_Couleurs")) nn_NbCouleurs = atoi(argu);
- else if(!strcmp(var,"NN_Threshold_Output")) nn_threshold_output = atoi(argu);
- else if(!strcmp(var,"NN_Influence_Luminosite")) nn_influ_lum = atof(argu);
- else if(!strcmp(var,"imgPath")) strcpy(imgPath, argu);
- else if(!strcmp(var,"NN_Lazy_Threshold")) nn_lazy_threshold = atoi(argu);
- else if(!strcmp(var,"Map_Error")) map_error = atoi(argu);
- else if(!strcmp(var,"Map_Error_Part")) map_error_part = atoi(argu);
- else if(!strcmp(var,"Angle_Ball")) angle_ball_weight= atoi(argu);
- else if(!strcmp(var,"Distance_Ball_Robot")) distance_ball_robot_weight = atoi(argu);
- else if(!strcmp(var,"Distance_Ball_Goal")) distance_ball_goal_weight = atoi(argu);
- else if(!strcmp(var,"Ball_Density")) ball_density_weight = atoi(argu);
- else if(!strcmp(var,"Ennemy_Presence")) ennemy_presence_weight = atoi(argu);
- else if(!strcmp(var,"Ball_Precision")) ball_precision_weight = atoi(argu);
- else if(!strcmp(var,"Skepticism")) skepticism_weight = atoi(argu);
- else if(!strcmp(var,"Skepticism_Max")) skepticism_max = atoi(argu);
- else if(!strcmp(var,"Minimum_Length_Zone")) minLengthZone = atoi(argu);
- else if(!strcmp(var,"Ball_Lost")) ball_lost_weight = atoi(argu);
- else if(!strcmp(var,"Ball_Bottom_Time_Out")) ball_bottom_time_out = atoi(argu);
- else if(!strcmp(var,"One_NN_Learning_Rate")) one_nn_learning_rate = atof(argu);
- else if(!strcmp(var,"One_NN_Learning_Iteration")) one_nn_learning_iteration = atoi(argu);
+ if (!strcmp (var,"NN_step_learning")) nn_sl = atof(argu);
+ else if (!strcmp (var,"NN_neighborhood_learning")) nn_nl = atof(argu);
+ else if (!strcmp (var,"NN_number_of_iteration_learning")) nn_nil = atol(argu);
+ else if (!strcmp (var,"NN_number_of_color_to_segment")) nn_NbCouleurs = atoi(argu);
+ else if (!strcmp (var,"NN_threshold_output")) nn_threshold_output = atoi(argu);
+ else if (!strcmp (var,"NN_luminosity_influence")) nn_influ_lum = atof(argu);
+ else if (!strcmp (var,"UI_img_path ")) strcpy(imgPath, argu);
+ else if (!strcmp (var,"NN_lazy_threshold")) nn_lazy_threshold = atoi(argu);
+ else if (!strcmp (var,"Map_error")) map_error = atoi(argu);
+ else if (!strcmp (var,"Map_error_part")) map_error_part = atoi(argu);
+ else if (!strcmp (var,"Map_angle_ball_weight")) angle_ball_weight= atoi(argu);
+ else if (!strcmp (var,"Map_distance_ball_robot_weight")) distance_ball_robot_weight = atoi(argu);
+ else if (!strcmp (var,"Map_distance_ball_goal_weight")) distance_ball_goal_weight = atoi(argu);
+ else if (!strcmp (var,"Map_ball_density_weight")) ball_density_weight = atoi(argu);
+ else if (!strcmp (var,"Map_ennemy_presence_weight")) ennemy_presence_weight = atoi(argu);
+ else if (!strcmp (var,"Map_ball_precision_weight")) ball_precision_weight = atoi(argu);
+ else if (!strcmp (var,"Map_skepticism_weight")) skepticism_weight = atoi(argu);
+ else if (!strcmp (var,"Map_skepticism_max")) skepticism_max = atoi(argu);
+ else if (!strcmp (var,"Map_ball_lost_weight")) ball_lost_weight = atoi(argu);
+ else if (!strcmp (var,"Map_ball_bottom_time_out")) ball_bottom_time_out = atoi(argu);
+ else if (!strcmp (var,"Group_minimum_length_zone")) minLengthZone = atoi(argu);
+ else if (!strcmp (var,"Group_jump_point_distance")) jumpPointDist = atoi(argu);
}
-/// Constructor
-/// @param *filename nom du fichier de config
-OConfig::OConfig(char *filename) {
-
- instance = this;
-
- Load (filename);
-
-
- colorMode = 0;
- color = NULL;
- node = NULL;
- index = NULL;
- LoadNNFile("rc/poids");
- LoadDistFile("rc/dist");
-}
-
-void OConfig::Load (char *filename)
+void
+OConfig::Load (char *filename)
{
const int NBARG = 3;
char *cut[NBARG] = {NULL};
@@ -95,31 +100,35 @@ void OConfig::Load (char *filename)
file = fopen(filename, "r");
if (!file) cerr << "OConfig::OConfig : Error during config file opening" << endl;
else cout << "Lecture du ficher de configuration" << endl;
-
-
+
+
// Parcours des lignes et analyse
- while(fgets(ligne, 50, file)) {
+ while(fgets(ligne, 50, file))
+ {
if (ligne[0] == '#') continue;
// Division du string
cut[0] = strtok(ligne, " \n");
if (!cut[0]) continue;
i=0;
- while ((cut[i] != NULL) && (i<(NBARG-1))) {
+ while ((cut[i] != NULL) && (i<(NBARG-1)))
+ {
i++;
cut[i] = strtok( NULL, " \t\n");
- }
+ }
Parse(cut[0], cut[2]);
- }
+ }
}
/// Chargement des poids d'un reseau de neurones
/// @param *filePath nom du fichier de poids a charger
-void OConfig::LoadNNFile(char *filePath) {
+void
+OConfig::LoadNNFile (char *filePath)
+{
const int NBARG = 4;
char *cut[NBARG] = {NULL};
FILE *file;
@@ -207,14 +216,16 @@ void OConfig::LoadNNFile(char *filePath) {
nbNodeMax = numNode;
fclose(file);
-
}
+
/// Creation d'un fichier de poids pour le reseau de neurones
/// @param *filename nom du fichier a creer
/// @param mode mode de l'espace de couleur
/// @param nbOutput nombre de couleurs a detecter du reseau de neurones
-void OConfig::CreateNNFile(const char *filename, int mode, int nbOutput) {
+void
+OConfig::CreateNNFile (const char *filename, int mode, int nbOutput)
+{
if (!node) {
cerr << "OConfig::CreateNNFile : NN non initialisé\n";
@@ -253,61 +264,10 @@ void OConfig::CreateNNFile(const char *filename, int mode, int nbOutput) {
}
-
-/// Chargement d'un fichier de seuils
-void OConfig::LoadThFile() {
- const int NBARG = 6;
- char *cut[NBARG] = {NULL};
- FILE *file;
- char ligne[50];
- int i;
- unsigned char *pColor;
-
- // Ouverture du fichier de conf
- file = fopen("threshold", "r");
- if (!file) {
- cerr << "OConfig::LoadThFile : Error during config file opening\n" << endl;
- return;
- }
-
- // Nombre de couleurs contenu dans le fichier
- int numColor=0;
- while(fgets(ligne, 50,file))
- numColor++;
-
- if (color) delete [] color;
- color = new unsigned char[numColor*3*2];
-
- // Parcours des lignes et analyse
- numColor=0;
- rewind(file);
- while(fgets(ligne, 50, file)) {
- if (ligne[0] == '#') continue;
-
- // Division du string
- cut[0] = strtok(ligne, " \t\n");
- if (!cut[0]) continue;
- i=0;
- pColor = &color[numColor*6];
- pColor[0] = (unsigned char)atoi(cut[0]);
- while ((cut[i] != NULL) && (i<(NBARG-1))) {
- i++;
- cut[i] = strtok( NULL, " \t\n");
- pColor[i] = (unsigned char)atoi(cut[i]);
- }
- numColor++;
- }
-
- nbCouleurMax = numColor;
-
- fclose(file);
-}
-
-
-
-/// Chargement de la tabPointle des distances
-void OConfig::LoadDistFile(char *filename) {
-
+/// Chargement de la liste des points pour les distances
+void
+OConfig::LoadDistFile (char *filename)
+{
FILE *file;
char buf[50];
@@ -329,43 +289,37 @@ void OConfig::LoadDistFile(char *filename) {
tabPoint.push_back(point[1]);
tabPoint.push_back(point[2]);
tabPoint.push_back(point[3]);
- //cout << point[0] << " " << point[1] << endl;
}
}
- cout << endl;
fclose(file);
+ // Nombre de points venant d'être chargé
nbDistPoint = tabPoint.size () / 4;
}
-/// Creation d'un fichier pour la tabPointle des distances
-void OConfig::CreateDistFile(char *filename, int numPoint) {
-
- if (tabPoint.size () /4) {
- cerr << "OConfig::CreateDistFile : tabPoint vide\n";
+
+/// Creation d'un fichier pour la liste des points pour les distances
+void
+OConfig::CreateDistFile (char *filename, int numPoint)
+{
+ if (tabPoint.size () == 0)
+ {
+ cerr << "OConfig::CreateDistFile : tabPoint vide" << endl;
return;
- }
+ }
// Ecriture dans un fichier
FILE *file;
file = fopen(filename, "w+");
-
+ // Remplissage du fichier
fprintf(file, "#imgX\timgY\tdistX\tdistY\n");
- // for (int i=0; i<numPoint; i++)
-// fprintf(file, "%i\t%i\t%i\t%i\n", tabPoint[i*4+0], tabPoint[i*4+1], tabPoint[i*4+2], tabPoint[i*4+3]);
-
- fclose(file);
-}
-
-
+ // for (int i=0; i<numPoint; i++)
+ // fprintf(file, "%i\t%i\t%i\t%i\n", tabPoint[i*4+0], tabPoint[i*4+1], tabPoint[i*4+2], tabPoint[i*4+3]);
-/// Destructor
-OConfig::~OConfig()
-{
+ fclose(file);
}
-