testLabeledSet.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. std::set_terminate ( __gnu_cxx::__verbose_terminate_handler );
  22. char configfile [300];
  23. struct CmdLineOption options[] = {
  24. {"config", "use config file", NULL, "%s", configfile},
  25. {NULL, NULL, NULL, NULL, NULL}
  26. };
  27. int ret;
  28. char *more_options[argc];
  29. ret = parse_arguments ( argc, ( const char** ) argv, options, more_options );
  30. if ( ret != 0 )
  31. {
  32. if ( ret != 1 ) fprintf ( stderr, "Error parsing command line !\n" );
  33. exit ( -1 );
  34. }
  35. Config conf ( configfile );
  36. MultiDataset md ( &conf );
  37. const LabeledSet *train = md["train"];
  38. const LabeledSet *test = md["test"];
  39. const ClassNames & cn = md.getClassNames ( "train" );
  40. fprintf ( stderr, "Training Dataset\n" );
  41. LOOP_ALL_S ( *train )
  42. {
  43. EACH_S ( classno, fn );
  44. fprintf ( stderr, "%s %s\n", cn.text ( classno ).c_str(), fn.c_str() );
  45. }
  46. fprintf ( stderr, "Test Dataset\n" );
  47. LOOP_ALL_S ( *test )
  48. {
  49. EACH_S ( classno, fn );
  50. fprintf ( stderr, "%s %s\n", cn.text ( classno ).c_str(), fn.c_str() );
  51. }
  52. return 0;
  53. }