testLabeledSet.cpp 1.6 KB

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