/** * Process the command line and initialize the variables * * @param argc The number of arguments * @param argv The arguments */ void process_command (int argc, char **argv, Arguments * args) { int i; int param_num = 0; int cutOffSet = 0; /******* Set up default values *******/ args->argc = argc; args->argv = argv; args->nIntrapersonal = 100; args->nExtrapersonal = 100; args->distanceMatrix = NULL; args->maxRank = -1; args->cutOffMode = CUTOFF_SIMPLE; args->cutOff = DEFAULT_CUTOFF_PERCENT_SIMPLE; args->dropNVectors = 0; debuglevel = 0; /******* Read command line arguments *******/ for (i = 1; i < argc; i++) { /* Catch common help requests */ if (readOption (argc, argv, &i, "-help" )) { usage(argv[0]); } else if (readOption (argc, argv, &i, "--help")) { usage(argv[0]); } /* Read in input directories */ else if (readOptionString (argc, argv, &i, "-imDir", &(args->imageDirectory))); else if (readOptionString (argc, argv, &i, "-distances", &(args->distanceMatrix))); /* Read in number of images to generate */ else if (readOptionInt (argc, argv, &i, "-ni", &(args->nIntrapersonal))); else if (readOptionInt (argc, argv, &i, "-ne", &(args->nExtrapersonal))); /* Read in maxRank */ else if (readOptionInt (argc, argv, &i, "-maxRank", &(args->maxRank))); /* Read in PCA training options */ else if (readOptionInt (argc, argv, &i, "-dropNVectors", &(args->dropNVectors))); else if (readOptionMatch(argc, argv, &i, "-cutOffMode", "NONE")) { args->cutOffMode = CUTOFF_NONE; } else if (readOptionMatch(argc, argv, &i, "-cutOffMode", "SIMPLE")) { args->cutOffMode = CUTOFF_SIMPLE; } else if (readOptionMatch(argc, argv, &i, "-cutOffMode", "ENERGY")) { args->cutOffMode = CUTOFF_ENERGY; } else if (readOptionMatch(argc, argv, &i, "-cutOffMode", "STRETCH")) { args->cutOffMode = CUTOFF_STRETCH; } else if (readOptionMatch(argc, argv, &i, "-cutOffMode", "CLASSES")) { args->cutOffMode = CUTOFF_CLASSES; } else if (readOptionDouble (argc, argv, &i, "-cutOff", &(args->cutOff))) { if ((args->cutOff <= 1.0) && (args->cutOff >= 0.000001)) { printf("WARNING: cutOff value is %f, expects percentage " "between 0.0 and 100.0", args->cutOff); printf(" will proceed assuming value is as desired."); } cutOffSet = 1; } /* other flags */ else if (readOption (argc, argv, &i, "-quiet")) { quiet = 1; } else if (readOptionInt (argc, argv, &i, "-debuglevel", &debuglevel)); /* check if the current argument is an unparsed option */ else if (checkBadOption(argc,argv,&i)); /* read required arguments */ else if (param_num == 0) { args->imageList = argv[i]; param_num++; } else if (param_num == 1) { args->trainingFilename = strdup (argv[i]); param_num++; } } /* make sure that there are the proper number of required arguments */ if (param_num != 2) { clParseError(argc,argv,i,"Wrong number of required arguments"); } /* Print out the program parameters for appropriate debug level */ DEBUG_INT (1, "Debuging enabled", debuglevel); if(debuglevel > 0) { printf("***************** Program Parameters *********************\n"); printf ("Image directory: %s\n", args->imageDirectory); printf ("Image list: %s\n", args->imageList); printf ("nIntrapersonal: %d\n", args->nIntrapersonal); printf ("nExtrapersonal: %d\n", args->nExtrapersonal); printf ("distanceMatrix: %s\n ", args->distanceMatrix); } }
void processCommand(int argc, char** argv, Arguments* args) { int i; int param_num = 0; /******* Set up default values *******/ args->geoType = CL_YES; args->histType = HIST_POST; args->nrmType = CL_YES; args->preNormType = CL_NO; args->maskType = CL_YES; args->preEdge = EDGE_PRE; args->postEdge = EDGE_POST; args->sizeWidth = SIZE_WIDTH; args->sizeHeight = SIZE_HEIGHT; args->eyeLx = EYE_LX; args->eyeLy = EYE_LY; args->eyeRx = EYE_RX; args->eyeRy = EYE_RY; args->scale = SCALE; args->noise = NOISE; args->shiftX = SHIFT_X; args->shiftY = SHIFT_Y; args->reflect = CL_NO; args->configSuffix = CL_NO; args->ellipseX = ELLIPSE_X; args->ellipseY = ELLIPSE_Y; args->ellipseA = ELLIPSE_A; args->ellipseB = ELLIPSE_B; args->inputDir = NULL; args->nrmDir = NULL; args->sfiDir = NULL; args->pgmDir = NULL; debuglevel = 0; /******* Read command line arguments *******/ for (i = 1;i < argc;i++) { /* Catch common help requests */ if (readOption (argc, argv, &i, "-help" )) { usage(argv[0]); } else if (readOption (argc, argv, &i, "--help")) { usage(argv[0]); } /******* Read in output directories *******/ else if (readOptionString(argc, argv, &i, "-nrm", &(args->nrmDir))){ } else if (readOptionString(argc, argv, &i, "-sfi", &(args->sfiDir))){ } else if (readOptionString(argc, argv, &i, "-pgm", &(args->pgmDir))){ } /* read in shift option */ else if (readOptionDouble2(argc, argv, &i, "-shift", &(args->shiftX), &(args->shiftY))) { } /******* Read in normalization options *******/ /* Mask parameters */ else if (readOptionDouble4(argc, argv, &i, "-mask-param", &(args->ellipseX), &(args->ellipseY), &(args->ellipseA), &(args->ellipseB))) { } else if (readOptionYesNo(argc, argv, &i, "-mask", &(args->maskType))) { } /* size parameters */ else if (readOptionInt2(argc, argv, &i, "-size",&(args->sizeWidth),&(args->sizeHeight))) { } /* geometric parameters */ else if (readOptionDouble4(argc, argv, &i, "-eye-target", &(args->eyeLx), &(args->eyeLy), &(args->eyeRx), &(args->eyeRy))) { } else if (readOptionYesNo (argc, argv, &i, "-geometric",&(args->geoType))) { } else if (readOptionYesNo (argc, argv, &i, "-reflect" ,&(args->reflect))) { } else if (readOption (argc, argv, &i, "-half")) { args->scale = 0.5; } else if (readOptionDouble (argc, argv, &i, "-scale", &(args->scale))) { } /* histogram parameters */ else if (readOptionMatch(argc, argv, &i, "-hist", "NONE")) { args->histType = HIST_NONE; } else if (readOptionMatch(argc, argv, &i, "-hist", "PRE" )) { args->histType = HIST_PRE; } else if (readOptionMatch(argc, argv, &i, "-hist", "POST")) { args->histType = HIST_POST; } /* Image Edge Smoothing */ else if (readOptionInt (argc, argv, &i, "-preEdge", &args->preEdge)) {} else if (readOptionInt (argc, argv, &i, "-postEdge", &args->postEdge)) {} /* Turn on noise */ else if (readOptionDouble(argc, argv, &i, "-noise", &(args->noise))) { } /* Turn of ZeroMeanOneStdDev */ else if (readOptionYesNo(argc, argv, &i, "-pixelNorm", &args->nrmType)) { } /* Turn of ZeroMeanOneStdDev */ else if (readOptionYesNo(argc, argv, &i, "-preNorm", &args->preNormType)) { } /* Turn on file name configuration encoding */ else if (readOption(argc, argv, &i, "-configSuffix")) { args->configSuffix = CL_YES; } /* other flags */ else if (readOption (argc, argv, &i, "-quiet")) { quiet = 1; } else if (readOptionInt (argc, argv, &i, "-debuglevel", &debuglevel)) {} /* check if the current argument is an unparsed option */ else if (checkBadOption(argc,argv,&i)) {} /* read required arguments */ else if (param_num == 0) { args->eyeFile = argv[i]; param_num++; } else if (param_num == 1) { args->inputDir = argv[i]; param_num++; } else{ clParseError(argc,argv,i,"Wrong number of required arguments"); } } /* make sure that there are the proper number of required arguments */ if (param_num != 2){ clParseError(argc,argv,i,"Wrong number of required arguments"); } /* Print out the program parameters for appropreate debug level */ DEBUG_CHECK(args->nrmDir || args->pgmDir || args->sfiDir,"You must specify at least one output directory."); DEBUG(1,"Debuging enabled"); if(debuglevel > 0){ printf("***************** Program Parameters *********************\n"); printf("Eye coordinates file: %s\n", args->eyeFile ? args->eyeFile : "NONE"); printf("Input directory: %s\n", args->inputDir ? args->inputDir : "NONE"); printf("nrm directory: %s\n", args->nrmDir ? args->nrmDir : "NONE"); printf("sfi directory: %s\n", args->sfiDir ? args->sfiDir : "NONE"); printf("pgm directory: %s\n", args->pgmDir ? args->pgmDir : "NONE"); printf("Output Size: %dX%d\n", args->sizeWidth, args->sizeHeight); printf("Geometric Norm: %s\n", args->geoType ? "YES" : "NO"); printf("Eye Target: (%0.2f %0.2f %0.2f %0.2f)\n", args->eyeLx, args->eyeLy, args->eyeRx, args->eyeRy); printf("Histogram Norm: %d\n", args->histType); printf("Value Norm: %s\n", args->nrmType ? "YES" : "NO"); printf("Apply Mask: %s\n", args->maskType ? "YES" : "NO"); printf("Mirror Reflect: %s\n", args->reflect ? "YES" : "NO"); printf("Config Suffix: %s\n", args->configSuffix ? "YES" : "NO"); printf("Mask Parameters: (%0.2f %0.2f %0.2f %0.2f)\n", args->ellipseX, args->ellipseY, args->ellipseA, args->ellipseB); } }
void process_command(int argc, char** argv, Arguments* args) { int i; int param_num = 0; int cutOffSet = 0; /* set to one if -cutOff is found so default does not change */ args->argc = argc; args->argv = argv; args->imageDirectory = strdup ("."); args->vecLength = 0; args->cutOffMode = CUTOFF_SIMPLE; args->cutOff = DEFAULT_CUTOFF_PERCENT_SIMPLE; args->uselda = 0; args->dropNVectors = 0; args->writeTextBasis = 0; args->writeTextValues = 0; args->writeTextInterm = 0; debuglevel = 0; for (i = 1;i < argc;i++) { /* Catch common help requests */ if (readOption (argc, argv, &i, "-help" )) { usage(argv[0]); } else if (readOption (argc, argv, &i, "--help")) { usage(argv[0]); } /* Read in input directories */ else if (readOptionString (argc, argv, &i, "-imDir", &(args->imageDirectory))); else if (readOptionInt (argc, argv, &i, "-vecLength", &(args->vecLength))); else if (readOptionInt (argc, argv, &i, "-dropNVectors", &(args->dropNVectors))); else if (readOptionMatch(argc, argv, &i, "-cutOffMode", "NONE")) { args->cutOffMode = CUTOFF_NONE; } else if (readOptionMatch(argc, argv, &i, "-cutOffMode", "SIMPLE")) { args->cutOffMode = CUTOFF_SIMPLE; } else if (readOptionMatch(argc, argv, &i, "-cutOffMode", "ENERGY")) { args->cutOffMode = CUTOFF_ENERGY; } else if (readOptionMatch(argc, argv, &i, "-cutOffMode", "STRETCH")) { args->cutOffMode = CUTOFF_STRETCH; } else if (readOptionMatch(argc, argv, &i, "-cutOffMode", "CLASSES")) { args->cutOffMode = CUTOFF_CLASSES; } else if (readOptionDouble (argc, argv, &i, "-cutOff", &(args->cutOff))) { if ((args->cutOff <= 1.0) && (args->cutOff >= 0.000001)) { printf("WARNING: cutOff value is %f, expects percentage " "between 0.0 and 100.0", args->cutOff); printf(" will proceed assuming value is as desired."); } cutOffSet = 1; } else if (readOption (argc, argv, &i, "-lda" )) { args->uselda = 1; } else if (readOption (argc, argv, &i, "-writeTextBasis" )) { args->writeTextBasis = 1; } else if (readOption (argc, argv, &i, "-writeTextValues" )) { args->writeTextValues = 1; } else if (readOption (argc, argv, &i, "-writeTextInterm" )) { args->writeTextInterm = 1; } else if (readOption (argc, argv, &i, "-outputMatlabAscii" )) { asciiFormat = 1; } /* other flags */ else if (readOption (argc, argv, &i, "-quiet")) { quiet = 1; } else if (readOptionInt (argc, argv, &i, "-debuglevel", &debuglevel)) {} /* read required arguments */ else if (param_num == 0) { args->imageList = strdup (argv[i]); param_num++; } else if (param_num == 1) { args->training_filename = strdup (argv[i]); param_num++; } else { clParseError(argc,argv,i,"Wrong number of required arguments"); } } /* make sure that there are the proper number of required arguments */ if (param_num != 2){ clParseError(argc,argv,i,"Wrong number of required arguments"); } /* Choose a default cutoff if none was specified */ if (!cutOffSet) { switch (args->cutOffMode) { case CUTOFF_NONE: case CUTOFF_SIMPLE: case CUTOFF_CLASSES: args->cutOff = DEFAULT_CUTOFF_PERCENT_SIMPLE; break; case CUTOFF_ENERGY: args->cutOff = DEFAULT_CUTOFF_PERCENT_ENERGY; break; case CUTOFF_STRETCH: args->cutOff = DEFAULT_CUTOFF_PERCENT_STRETCH; break; } } if ((!args->uselda) && (args->cutOffMode == CUTOFF_CLASSES)) { printf("Warning: Cutoff Mode Classes meant for use with lda only.\n"); } /* Print out the program parameters for appropreate debug level */ DEBUG(1,"Debuging enabled"); if(debuglevel > 0){ printf ("***************** Program Parameters *********************\n"); printf ("Image directory: %s\n", args->imageDirectory); printf ("Image list: %s\n", args->imageList); printf ("Training file: %s\n", args->training_filename); printf ("vecLength: %d\n", args->vecLength); printf ("useLda: %s\n", args->uselda ? "YES" : "NO"); printf ("cutOff: %f\n", args->cutOff); } }