Example.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #ifndef EXAMPLEINCLUDE
  2. #define EXAMPLEINCLUDE
  3. /**
  4. * @file Example.h
  5. * @brief data caching of several feature images and many more
  6. * @author Erik Rodner
  7. * @date 04/21/2008
  8. */
  9. #include "CachedExample.h"
  10. namespace OBJREC {
  11. /** Cached example with window information */
  12. class Example
  13. {
  14. public:
  15. /** weight of example */
  16. double weight;
  17. /** complete image example */
  18. CachedExample *ce;
  19. /** x position of window */
  20. long long int x;
  21. /** y position of window */
  22. long long int y;
  23. /** width of window */
  24. int width;
  25. /** height of window */
  26. int height;
  27. //! if some examples are related, they have the same position
  28. int position;
  29. //! scale of the feature
  30. double scale;
  31. /** evil workaround: store simple vector example */
  32. NICE::Vector *vec;
  33. /** evil workaround: store sparse vector example */
  34. NICE::SparseVector *svec;
  35. /** simple constructor, initialize everything with 0
  36. */
  37. Example();
  38. /** constructor using a window covering the whole image
  39. @param ce associated image data
  40. */
  41. Example ( CachedExample *_ce );
  42. /** constructor
  43. @param ce associated image data
  44. @param x x position of window
  45. @param y y position of window
  46. @param weight weight of example
  47. */
  48. Example ( CachedExample *ce, int x, int y, double weight = 1.0 );
  49. /** constructor
  50. @param ce associated image data
  51. @param x x position of window
  52. @param y y position of window
  53. @param weight weight of example
  54. */
  55. Example ( CachedExample *ce, int x, int y, int width, int height, double weight = 1.0 );
  56. /** evil workaround: simple constructors for std::vector examples
  57. @param vec simple feature vector
  58. @param weight optional weight
  59. */
  60. Example ( NICE::Vector *vec, double weight = 1.0 );
  61. /**
  62. * copy constructor
  63. * @param ex input Example
  64. */
  65. Example ( const Example &ex);
  66. /**
  67. * copies the values of ex in this example
  68. * @param ex input Example
  69. */
  70. void copy ( const Example &ex);
  71. /** destructor */
  72. ~Example ();
  73. /** delete all data associated with this example
  74. (sparse vector, vector, cached example, etc.) */
  75. void clean ();
  76. /**
  77. * load from file (warning: no cachedexamples supported yet
  78. * @param is file
  79. * @param format
  80. */
  81. void restore (std::istream & is, int format = 0);
  82. /**
  83. * write to file (warning: no cachedexamples supported yet
  84. * @param is file
  85. * @param format
  86. */
  87. void store (std::ostream & os, int format = 0) const;
  88. };
  89. /** labeled pair of Example
  90. @see Example */
  91. class Examples : public std::vector< std::pair<int, Example> >
  92. {
  93. public:
  94. std::string filename;
  95. inline int getMaxClassNo () const
  96. {
  97. int maxClassno = -1;
  98. for ( const_iterator i = begin(); i != end(); i++ )
  99. if ( i->first > maxClassno )
  100. maxClassno = i->first;
  101. return maxClassno;
  102. }
  103. /** delete all data associated with all examples
  104. (sparse vector, vector, cached example, etc.) */
  105. void clean ();
  106. };
  107. } // namespace
  108. #endif