testCachedExample.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifndef __clang__
  18. #ifndef __llvm__
  19. std::set_terminate ( __gnu_cxx::__verbose_terminate_handler );
  20. #endif
  21. #endif
  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. int i = 0;
  37. while ( more_options[i] != NULL )
  38. {
  39. std::string filename ( more_options[i] );
  40. fprintf ( stderr, "Filename: %s\n", filename.c_str() );
  41. CachedExample ce ( filename );
  42. NICE::MultiChannelImage3DT<int> & img = ce.getIChannel ( CachedExample::I_COLOR );
  43. NICE::MultiChannelImage3DT<double> & imgc = ce.getDChannel ( CachedExample::D_INTEGRALCOLOR );
  44. imgc.reInitFrom ( img );
  45. for ( uint j = 0 ; j < img.channels(); j++ )
  46. {
  47. ImageT<double> tmp = imgc.getChannelT(j);
  48. GenericImageTools::calcIntegralImage ( tmp, img.getChannel(j), img.width(), img.height() );
  49. }
  50. Image visimg = imgc.getChannel ( 0 );
  51. showImage ( visimg );
  52. ce.dropPreCached();
  53. #ifndef NOVISUAL
  54. getchar();
  55. #endif
  56. imgc = ce.getDChannel ( CachedExample::D_INTEGRALCOLOR );
  57. visimg = imgc.getChannel ( 0 );
  58. showImage ( visimg );
  59. i++;
  60. }
  61. return 0;
  62. }