FCFPFeature.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * @file FCFPFeature.cpp
  3. * @author Erik Rodner
  4. * @date 11/15/2007
  5. */
  6. #include <iostream>
  7. #include <core/imagedisplay/ImageDisplay.h>
  8. #include "FCFPFeature.h"
  9. #include "vislearning/cbaselib/FeaturePool.h"
  10. #include "vislearning/baselib/ICETools.h"
  11. using namespace OBJREC;
  12. using namespace std;
  13. using namespace NICE;
  14. FCFPFeature::FCFPFeature( const Config * conf ) :
  15. FeatureFactory ( conf ), imgf (conf, "FCFPFeature" )
  16. {
  17. }
  18. FCFPFeature::~FCFPFeature()
  19. {
  20. }
  21. int FCFPFeature::convertRGB ( const NICE::ColorImage & img, NICE::Vector & vec )
  22. {
  23. FeaturePool fpool;
  24. imgf.fillFeaturePool ( fpool, false );
  25. vec.resize ( fpool.size() );
  26. CachedExample ce ( img );
  27. Example example ( &ce );
  28. imgf.fillExample ( example.ce );
  29. fprintf (stderr, "Total size of feature vector will be: %d\n", fpool.size() );
  30. uint index = 0;
  31. for ( FeaturePool::const_iterator i = fpool.begin();
  32. i != fpool.end();
  33. i++, index++ )
  34. {
  35. Feature *f = i->second;
  36. vec[index] = f->val ( &example );
  37. }
  38. example.clean();
  39. fpool.destroy();
  40. return 0;
  41. }
  42. int FCFPFeature::convert ( const NICE::Image & img, NICE::Vector & vec )
  43. {
  44. FeaturePool fpool;
  45. imgf.fillFeaturePool ( fpool, false );
  46. vec.resize ( fpool.size() );
  47. CachedExample ce ( img );
  48. Example example ( &ce );
  49. imgf.fillExample ( example.ce );
  50. fprintf (stderr, "Total size of feature std::vector will be: %d\n", fpool.size() );
  51. uint index = 0;
  52. for ( FeaturePool::const_iterator i = fpool.begin();
  53. i != fpool.end();
  54. i++, index++ )
  55. {
  56. Feature *f = i->second;
  57. vec[index] = f->val ( &example );
  58. }
  59. // do not clean this stuff: example.clean();
  60. fpool.destroy();
  61. return 0;
  62. }