// Beispielhafter Aufruf: BUILD_x86_64/progs/testSemanticSegmentation -config /** * @file testSemanticSegmentation.cpp * @brief test semantic segmentation routines * @author Erik Rodner * @date 03/20/2008 */ #ifdef NICE_USELIB_OPENMP #include #endif #include "core/basics/Config.h" #include #include #include "vislearning/cbaselib/MultiDataset.h" #include "core/image/MultiChannelImageT.h" #include using namespace OBJREC; using namespace NICE; using namespace std; /** test semantic segmentation routines */ int main( int argc, char **argv ) { Config conf( argc, argv ); MultiDataset md( &conf ); const ClassNames & classNames = md.getClassNames( "train" ); const LabeledSet *testFiles = md["test"]; set forbidden_classes; std::string forbidden_classes_s = conf.gS( "analysis", "forbidden_classes", "" ); classNames.getSelection( forbidden_classes_s, forbidden_classes ); LOOP_ALL_S( *testFiles ) { EACH_INFO( classno, info ); std::string file = info.img(); NICE::Image lm; NICE::MultiChannelImageT probabilities; if ( info.hasLocalizationInfo() ) { const LocalizationResult *l_gt = info.localization(); lm.resize( l_gt->xsize, l_gt->ysize ); lm.set( 0 ); l_gt->calcLabeledImage( lm, classNames.getBackgroundClass() ); } NICE::Image lm_gt; if ( info.hasLocalizationInfo() ) { const LocalizationResult *l_gt = info.localization(); lm_gt.resize( l_gt->xsize, l_gt->ysize ); lm_gt.set( 0 ); fprintf( stderr, "testSemanticSegmentation: Generating Labeled NICE::Image (Ground-Truth)\n" ); l_gt->calcLabeledImage( lm_gt, classNames.getBackgroundClass() ); } set classes; for ( int x = 0; x < lm_gt.width(); x++ ) { for ( int y = 0; y < lm_gt.height(); y++ ) { classes.insert( lm_gt.getPixel( x, y ) ); } } // write allowed classes string cndir = conf.gS( "SemSegCsurka", "cndir", "" ); std::vector< std::string > list; StringTools::split( file, '/', list ); cout << cndir << "/" << list.back() << ".dat" << endl; string cname = list.back(); if ( cndir != "" ) { string fname = cndir + "/" + cname + ".dat"; cout << fname << endl; ofstream outfile( fname.c_str() ); set::iterator theIterator; for ( theIterator = classes.begin(); theIterator != classes.end(); theIterator++ ) { outfile << *theIterator << endl; } } else { cerr << "please define directory for writing filenames in config: SemSegCsurka::cndir" << endl; exit( -1 ); } } return 0; }