testCachedExample.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 );
  41. for ( uint j = 0 ; j < img.channels(); j++ )
  42. {
  43. ImageT<double> tmp = imgc[j];
  44. GenericImageTools::calcIntegralImage ( tmp, img[j], img.width(), img.height() );
  45. }
  46. Image visimg = imgc.getChannel ( 0 );
  47. showImage ( visimg );
  48. ce.dropPreCached();
  49. #ifndef NOVISUAL
  50. getchar();
  51. #endif
  52. imgc = ce.getDChannel ( CachedExample::D_INTEGRALCOLOR );
  53. visimg = imgc.getChannel ( 0 );
  54. showImage ( visimg );
  55. i++;
  56. }
  57. return 0;
  58. }