123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #ifndef EXAMPLEINCLUDE
- #define EXAMPLEINCLUDE
- /**
- * @file Example.h
- * @brief data caching of several feature images and many more
- * @author Erik Rodner
- * @date 04/21/2008
- */
- #include "CachedExample.h"
- namespace OBJREC {
- /** Cached example with window information */
- class Example
- {
- public:
- /** weight of example */
- double weight;
- /** complete image example */
- CachedExample *ce;
- /** x position of window */
- long long int x;
- /** y position of window */
- long long int y;
- /** width of window */
- int width;
- /** height of window */
- int height;
- //! if some examples are related, they have the same position
- int position;
- //! scale of the feature
- double scale;
- /** evil workaround: store simple vector example */
- NICE::Vector *vec;
- /** evil workaround: store sparse vector example */
- NICE::SparseVector *svec;
- /** simple constructor, initialize everything with 0
- */
- Example();
- /** constructor using a window covering the whole image
- @param ce associated image data
- */
- Example ( CachedExample *_ce );
- /** constructor
- @param ce associated image data
- @param x x position of window
- @param y y position of window
- @param weight weight of example
- */
- Example ( CachedExample *ce, int x, int y, double weight = 1.0 );
- /** constructor
- @param ce associated image data
- @param x x position of window
- @param y y position of window
- @param weight weight of example
- */
- Example ( CachedExample *ce, int x, int y, int width, int height, double weight = 1.0 );
- /** evil workaround: simple constructors for std::vector examples
- @param vec simple feature vector
- @param weight optional weight
- */
- Example ( NICE::Vector *vec, double weight = 1.0 );
- /**
- * copy constructor
- * @param ex input Example
- */
- Example ( const Example &ex );
- /**
- * copies the values of ex in this example
- * @param ex input Example
- */
- void copy ( const Example &ex );
- /** destructor */
- ~Example ();
- /** delete all data associated with this example
- (sparse vector, vector, cached example, etc.) */
- void clean ();
- /**
- * load from file (warning: no cachedexamples supported yet
- * @param is file
- * @param format
- */
- void restore ( std::istream & is, int format = 0 );
- /**
- * write to file (warning: no cachedexamples supported yet
- * @param is file
- * @param format
- */
- void store ( std::ostream & os, int format = 0 ) const;
- };
- /** labeled pair of Example
- @see Example */
- class Examples : public std::vector< std::pair<int, Example> >
- {
- public:
- std::string filename;
- inline int getMaxClassNo () const
- {
- int maxClassno = -1;
- for ( const_iterator i = begin(); i != end(); i++ )
- if ( i->first > maxClassno )
- maxClassno = i->first;
- return maxClassno;
- }
- /** delete all data associated with all examples
- (sparse vector, vector, cached example, etc.) */
- void clean ();
- };
- } // namespace
- #endif
|