test.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Beispielhafter Aufruf: BUILD_x86_64/progs/testSemanticSegmentation -config <CONFIGFILE>
  2. /**
  3. * @file test.cpp
  4. * @brief simple test program for everything
  5. * @author Björn Fröhlich
  6. * @date 03/10/2010
  7. */
  8. #ifdef NICE_USELIB_OPENMP
  9. #include <omp.h>
  10. #endif
  11. #include <iostream>
  12. #include <fstream>
  13. #include "objrec/segmentation/RSMeanShift.h"
  14. #include "objrec/segmentation/RSCache.h"
  15. #include "objrec/baselib/Globals.h"
  16. using namespace std;
  17. using namespace OBJREC;
  18. int main(int argc, char **argv)
  19. {
  20. //popen test
  21. string fn = "/tmp/img.ppm";
  22. std::string call = "ls *";
  23. const int buffersize = 65536;
  24. char *buffer = new char [buffersize];
  25. FILE *f = popen ( call.c_str(), "r" );
  26. cout << call << endl;
  27. if ( f == NULL )
  28. {
  29. fprintf (stderr, "FATAL ERROR, unable to run program\n");
  30. return -1;
  31. }
  32. while ( ! feof(f) )
  33. {
  34. if ( fgets ( buffer, buffersize, f ) <= 0 )
  35. {
  36. break;
  37. } else {
  38. fprintf (stderr, "%s", buffer );
  39. }
  40. }
  41. pclose(f);
  42. //openMP test
  43. #pragma omp parallel for
  44. for(int i = 0; i < 3; i++)
  45. {
  46. cout << i << endl;
  47. }
  48. Config * conf = new Config();
  49. RegionSegmentationMethod *tmprsm = new RSMeanShift(conf);
  50. RSCache rsm( conf, tmprsm );
  51. Image cimg(fn);
  52. Matrix mask;
  53. Globals::setCurrentImgFN ( fn );
  54. rsm.segRegions (cimg, mask);
  55. return 0;
  56. }