/** * @file testFeatureLearning.cpp * @brief test the feature learning routines to incrementally increase / adapt the codebook currently used * @author Alexander Freytag * @date 11-04-2013 */ #include #include #include #include #include #include #include #include #include #include "vislearning/featureLearning/FeatureLearningGeneric.h" #include "vislearning/featureLearning/FeatureLearningClusterBased.h" using namespace std; using namespace NICE; using namespace OBJREC; /** test feature learning routines */ int main( int argc, char **argv ) { std::set_terminate( __gnu_cxx::__verbose_terminate_handler ); Config * conf = new Config ( argc, argv ); bool showTrainingImages= conf->gB( "featureLearning", "showTrainingImages", false ); bool showTestImages= conf->gB( "featureLearning", "showTestImages", false ); ResourceStatistics rs; std::string resultdir; //********************************************** // // READ INITIAL TRAINING SET TO COMPUTE // AN INITIAL CODEBOOK // //********************************************** std::cerr << " READ INITIAL TRAINING SET TO COMPUTE AN INITIAL CODEBOOK" << std::endl; MultiDataset md( conf ); const LabeledSet *trainFiles = md["train"]; //********************************************** // // SET UP THE FEATURE LEARNING ALGO // //********************************************** OBJREC::FeatureLearningGeneric * featureLearning; featureLearning = new OBJREC::FeatureLearningClusterBased( conf, &md ); //print computed cluster centers -- this is NOT recommended :) // prototypes.store(std::cerr); //evaluate how well the training images are covered with our initial codebook //that is, compute these nice "novelty maps" per feature LOOP_ALL_S( *trainFiles ) { EACH_INFO( classno, info ); std::string filename = info.img(); featureLearning->evaluateCurrentCodebook( filename ); } //********************************************** // // FOR-LOOP OVER UNSEEN IMAGES // // EXTRACT FEATURES, CLUSTER THEM, TAKE // MOST "VALUABLE" CLUSTERS AS NEW // REPRESENTATIVES IN AN INCREASED CODEBOK // //********************************************** const LabeledSet *testFiles = md["test"]; std::cerr << "start looping over all files" << std::endl; LOOP_ALL_S( *testFiles ) { EACH_INFO( classno, info ); std::string file = info.img(); NICE::ColorImage orig( file ); showImage( orig, "Input" ); } //Loop over all test images return 0; }