testLabeledSet.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @file testLabeledSet.cpp
  3. * @brief test multidataset
  4. * @author Erik Rodner
  5. * @date 03/03/2008
  6. */
  7. #include "core/vector/VectorT.h"
  8. #include "core/vector/MatrixT.h"
  9. #include "core/image/ImageT.h"
  10. #include <core/basics/Config.h>
  11. #include <vislearning/baselib/cmdline.h>
  12. #include <vislearning/cbaselib/MultiDataset.h>
  13. using namespace OBJREC;
  14. using namespace NICE;
  15. using namespace std;
  16. /**
  17. test multidataset
  18. */
  19. int main ( int argc, char **argv )
  20. {
  21. #ifndef __clang__
  22. #ifndef __llvm__
  23. std::set_terminate ( __gnu_cxx::__verbose_terminate_handler );
  24. #endif
  25. #endif
  26. char configfile [300];
  27. struct CmdLineOption options[] = {
  28. {"config", "use config file", NULL, "%s", configfile},
  29. {NULL, NULL, NULL, NULL, NULL}
  30. };
  31. int ret;
  32. char *more_options[argc];
  33. ret = parse_arguments ( argc, ( const char** ) argv, options, more_options );
  34. if ( ret != 0 )
  35. {
  36. if ( ret != 1 ) fprintf ( stderr, "Error parsing command line !\n" );
  37. exit ( -1 );
  38. }
  39. Config conf ( configfile );
  40. MultiDataset md ( &conf );
  41. const LabeledSet *train = md["train"];
  42. const LabeledSet *test = md["test"];
  43. const ClassNames & cn = md.getClassNames ( "train" );
  44. fprintf ( stderr, "Training Dataset\n" );
  45. LOOP_ALL_S ( *train )
  46. {
  47. EACH_S ( classno, fn );
  48. fprintf ( stderr, "%s %s\n", cn.text ( classno ).c_str(), fn.c_str() );
  49. }
  50. fprintf ( stderr, "Test Dataset\n" );
  51. LOOP_ALL_S ( *test )
  52. {
  53. EACH_S ( classno, fn );
  54. fprintf ( stderr, "%s %s\n", cn.text ( classno ).c_str(), fn.c_str() );
  55. }
  56. return 0;
  57. }