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.cc65
1 files changed, 37 insertions, 28 deletions
diff --git a/2004/i/nono/src/ovision/oconfig.cc b/2004/i/nono/src/ovision/oconfig.cc
index 5fbd46e..f424159 100644
--- a/2004/i/nono/src/ovision/oconfig.cc
+++ b/2004/i/nono/src/ovision/oconfig.cc
@@ -36,7 +36,7 @@ void OConfig::Parse(char *var, char *arg) {
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);
@@ -44,6 +44,7 @@ void OConfig::Parse(char *var, char *arg) {
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);
@@ -60,13 +61,8 @@ void OConfig::Parse(char *var, char *arg) {
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,"Source"))
- {
- if (!strcmp(argu, "file")) source = SOURCE_FILE;
- else if (!strcmp(argu, "usbcam")) source = SOURCE_USB_CAM;
- else if (!strcmp(argu, "cam")) source = SOURCE_CAM;
- }
-
+ 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);
}
@@ -74,14 +70,27 @@ void OConfig::Parse(char *var, char *arg) {
/// @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)
+{
const int NBARG = 3;
char *cut[NBARG] = {NULL};
FILE *file;
char ligne[50];
int i;
- instance = this;
-
// Ouverture du fichier de conf
file = fopen(filename, "r");
if (!file) cerr << "OConfig::OConfig : Error during config file opening" << endl;
@@ -105,12 +114,6 @@ OConfig::OConfig(char *filename) {
Parse(cut[0], cut[2]);
}
- colorMode = 0;
- color = NULL;
- node = NULL;
- index = NULL;
- LoadNNFile("rc/poids");
- LoadDistFile("rc/dist");
}
@@ -314,26 +317,32 @@ void OConfig::LoadDistFile(char *filename) {
cerr << "OConfig::LoadDistFile : Error during poids file opening" << endl;
return;
}
-
- int i=0;
- while (i<NB_POINTS)
+
+ // Parcours des lignes et analyse
+ int point[4];
+ while((fgets(buf, 50, file)) && (!feof(file)))
{
- fgets(buf, 50, file);
- if (buf[0] != '#')
+ if ((buf[0] >= '0') && (buf[0] <= '9'))
{
- sscanf(buf, "%i\t%i\t%i\t%i\n", &tabPoint[i][0], &tabPoint[i][1], &tabPoint[i][2], &tabPoint[i][3]);
- i++;
+ sscanf(buf, "%i\t%i\t%i\t%i\n", &point[0], &point[1], &point[2], &point[3]);
+ tabPoint.push_back(point[0]);
+ 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);
+ nbDistPoint = tabPoint.size () / 4;
}
/// Creation d'un fichier pour la tabPointle des distances
-void OConfig::CreateDistFile(char *filename) {
+void OConfig::CreateDistFile(char *filename, int numPoint) {
- if (!tabPoint) {
+ if (tabPoint.size () /4) {
cerr << "OConfig::CreateDistFile : tabPoint vide\n";
return;
}
@@ -345,8 +354,8 @@ void OConfig::CreateDistFile(char *filename) {
fprintf(file, "#imgX\timgY\tdistX\tdistY\n");
- for (int i=0; i<NB_POINTS; i++)
- fprintf(file, "%i\t%i\t%i\t%i\n", tabPoint[i][0], tabPoint[i][1], tabPoint[i][2], tabPoint[i][3]);
+ // 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);
}