00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #include <iostream>
00056 #include "NormFeat.h"
00057 #include <alize.h>
00058 #include <liatools.h>
00059
00060 int main (int argc, char *argv[])
00061 {
00062 using namespace std;
00063 using namespace alize;
00064
00065 ConfigChecker cc;
00066 cc.addStringParam("config", false, true, "default config filename");
00067 cc.addStringParam("mode", true, true, "<norm: mean, var, warp normalization | info: save stats of file | featmap: feature mapping | FA EigenChannel Compensation >");
00068 cc.addStringParam("inputFeatureFilename",true,true,"input feature - could be a simple feature file or a list of filename");
00069 cc.addStringParam("labelSelectedFrames",true,true,"Only the frames from segments with this label will be used");
00070 cc.addBooleanParam("fileMode",false,true,"One normalisation for all the selected data, could be applied after segmental/window modes if both are selected");
00071 cc.addBooleanParam("segmentalMode",false,true,"if set to true, one normalisation by segment is computed");
00072 cc.addBooleanParam("windowMode",false,true,"if set to true, the normalisation is computed by windows");
00073 cc.addFloatParam("windowDuration",false,true,"Length of the window (for window mode) in seconds (default=5)");
00074 cc.addFloatParam("windowComp",false,true,"compensation factor for window mode (default =1.0 - no compensation");
00075 cc.addBooleanParam("writeAllFeatures",false,true,"if set to true,values for all the input frames are outputed (default true)");
00076 cc.addStringParam("featureServerMode",true,true,"FEATURE_WRITABLE to write normalized features");
00077 cc.addStringParam("outputInfoFilename",false,true,"The complete output filename for the info file");
00078 cc.addBooleanParam("cmsOnly",false,true,"If cmsOnly is set, only remove means from features (default false)");
00079 cc.addBooleanParam("varOnly",false,true,"If cmsOnly is set, reduce only variance from features (default false)");
00080 cc.addBooleanParam("warp",false,true,"If warp is set, uses featureWarping (default false)");
00081 cc.addIntegerParam("warpBinCount",false,true,"If warp is set, this parameter fixes the number of bins in the data histo (default=40)");
00082 cc.addStringParam("warpGaussHistoFilename",false,true,"for warping, if this parameter is set, it loads the destination histo, default it creates it (N(0,1))");
00083 cc.addBooleanParam("warpAdd01Norm",false,true,"for warping, add a global N(0,1) normalisation after warping (default false)");
00084 cc.addStringParam("externalStatsFilename",false,true,"filename containing external stats to apply for normalization, usually obtained with info mode (opt.)");
00085 cc.addFloatParam("frameLength",false,true,"length of a frame, by default 10ms");
00086 try
00087 {
00088 CmdLine cmdLine (argc, argv);
00089 if (cmdLine.displayHelpRequired ()){
00090 cout << "NormFeat" << endl;
00091 cout << "NormFeat.exe --config <foo.cfg> --inputFeatureFileName <foo.prm> --mode <norm|info|featMap>"<< endl;
00092 cout<<cc.getParamList()<<endl;
00093 }
00094 else if (cmdLine.displayVersionRequired ())
00095 cout << "Version 2.0" << endl;
00096 else{
00097 Config tmp;
00098 cmdLine.copyIntoConfig (tmp);
00099 Config config;
00100 if (tmp.existsParam("config")) config.load(tmp.getParam("config"));
00101 cmdLine.copyIntoConfig(config);
00102 cc.check(config);
00103 debug=config.getParam_debug();
00104 if (config.existsParam("verbose")) verbose=config.getParam("verbose").toBool();
00105 else verbose=false;
00106 if (verbose) verboseLevel=1;else verboseLevel=0;
00107 if (config.existsParam("verboseLevel"))verboseLevel=config.getParam("verboseLevel").toLong();
00108 if (verboseLevel>0) verbose=true;
00109 String mode=config.getParam("mode");
00110 if ( mode == "norm"){normFeat(config);}
00111 else if ( mode == "info"){infoFeat(config);}
00112 else if (mode == "featMap"){featMap(config);}
00113 else if (mode == "NAP"){normFeatNAP(config);}
00114 else if (mode == "FA"){normFeatFA(config);}
00115 else if (mode == "LFA"){normFeatLFA(config);}
00116 else throw Exception("Error: Mode unknown!",__FILE__,__LINE__);
00117 }
00118 }
00119 catch (alize::Exception & e) {cout << e.toString () << endl << cc.getParamList() << endl;}
00120 #ifdef NDEBUG
00121 cout<<"*** Objects created and destroyed **"<<Object::getCreationCounter()<<"-"<<Object::getDestructionCounter()<<endl;
00122 #endif
00123 return 0;
00124 }