testLabeledSet.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * @file testLabeledSet.cpp
  3. * @brief test multidataset
  4. * @author Erik Rodner
  5. * @date 03/03/2008
  6. */
  7. #ifdef NOVISUAL
  8. #include <vislearning/nice_nonvis.h>
  9. #else
  10. #include <vislearning/nice.h>
  11. #endif
  12. #include <core/basics/Config.h>
  13. #include <vislearning/baselib/cmdline.h>
  14. #include <vislearning/cbaselib/MultiDataset.h>
  15. using namespace OBJREC;
  16. // refactor-nice.pl: check this substitution
  17. // old: using namespace ice;
  18. using namespace NICE;
  19. using namespace std;
  20. /**
  21. test multidataset
  22. */
  23. int main (int argc, char **argv)
  24. {
  25. std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
  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. }