testCachedExample.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * @file testCachedExample.cpp
  3. * @brief test cached example implementation
  4. * @author Erik Rodner
  5. * @date 09/12/2008
  6. */
  7. #include <core/imagedisplay/ImageDisplay.h>
  8. #include <core/basics/Config.h>
  9. #include <vislearning/baselib/cmdline.h>
  10. #include <vislearning/image/GenericImageTools.h>
  11. #include <vislearning/cbaselib/CachedExample.h>
  12. using namespace OBJREC;
  13. using namespace NICE;
  14. using namespace std;
  15. int main (int argc, char **argv)
  16. {
  17. std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
  18. char configfile [300];
  19. struct CmdLineOption options[] = {
  20. {"config", "use config file", NULL, "%s", configfile},
  21. {NULL, NULL, NULL, NULL, NULL}
  22. };
  23. int ret;
  24. char *more_options[argc];
  25. ret = parse_arguments( argc, (const char**)argv, options, more_options);
  26. if ( ret != 0 )
  27. {
  28. if ( ret != 1 ) fprintf (stderr, "Error parsing command line !\n");
  29. exit (-1);
  30. }
  31. Config conf ( configfile );
  32. int i = 0;
  33. while ( more_options[i] != NULL )
  34. {
  35. std::string filename ( more_options[i] );
  36. fprintf (stderr, "Filename: %s\n", filename.c_str() );
  37. CachedExample ce ( filename );
  38. NICE::MultiChannelImageT<int> & img = ce.getIChannel(CachedExample::I_COLOR);
  39. NICE::MultiChannelImageT<double> & imgc = ce.getDChannel(CachedExample::D_INTEGRALCOLOR);
  40. imgc.reInitFrom ( img, true );
  41. for ( uint j = 0 ; j < img.numChannels; j++ )
  42. GenericImageTools::calcIntegralImage ( imgc.data[j], img.data[j], img.xsize, img.ysize );
  43. Image visimg = imgc.getChannel(0);
  44. showImage(visimg);
  45. ce.dropPreCached();
  46. #ifndef NOVISUAL
  47. getchar();
  48. #endif
  49. imgc = ce.getDChannel ( CachedExample::D_INTEGRALCOLOR );
  50. visimg = imgc.getChannel(0);
  51. showImage(visimg);
  52. i++;
  53. }
  54. return 0;
  55. }