/** * @file NoveltyDetectorCodebookLevel.h * @brief Compute novelty of images based on relations between extracted features and current codebook * @author Alexander Freytag * @date 02-05-2013 (dd-mm-yyyy) */ #ifndef _INCLUDENOVELTYDETECTIONCODEBOOKLEVEL #define _INCLUDENOVELTYDETECTIONCODEBOOKLEVEL #include "NoveltyDetector.h" //core #include #include // vislearning #include // #include // #include namespace OBJREC { /** * @class NoveltyDetectorCodebookLevel * @brief Compute novelty of images based on relations between extracted features and current codebook * @author Alexander Freytag * @date 02-05-2013 (dd-mm-yyyy) */ class NoveltyDetectorCodebookLevel : public NoveltyDetector { protected: /************************ * * protected variables * **************************/ NICE::VectorDistance * distFunction; LocalFeatureRepresentation * featureExtractor; //! The currently known "cluster" centers, which are used for BoW histogram computation (i.e., the codebook) NICE::VVector * prototypes; //! was an initial codebook already computed? bool b_loadInitialCodebook; //!shall the initially computed codebook be stored somewhere? bool b_saveInitialCodebook; //! where should an initial codebook be located, i.e., read from and written to? std::string cacheInitialCodebook; //! did we compute a codebook on our own or do we use simply a pointer to an external codebook? bool externalCodebook; /************************ * * protected methods * **************************/ void setFeatureExtractor( const bool & _setForTraining = false); void extractFeaturesFromTrainingImages( const OBJREC::MultiDataset *_md, NICE::VVector & examplesTraining ); virtual bool loadInitialCodebook ( ); virtual bool writeInitialCodebook ( ); public: /** constructor * @param _conf needs a configfile * @param _md and a MultiDataset (contains images and other things) * @param _section section information for parsing config files */ NoveltyDetectorCodebookLevel ( const NICE::Config *_conf, const OBJREC::MultiDataset *_md , const std::string & _section = "noveltyDetector"); /** simple destructor */ virtual ~NoveltyDetectorCodebookLevel(); /** * @brief Evaluate whether or not the image of the specified filename is novel with respect to the current known examples or not * @author Alexander Freytag * @date 02-05-2013 (dd-mm-yyyy) * @param _filename of the new image * @return bool (true: class/content/... of image is novel, false: class/content/... of image is known) * @note This function has to be overloaded by all subclasses! */ virtual bool evaluateNoveltyOfImage ( const std::string & _filename ) = 0; /** * @brief Evaluate whether or not the image of the specified filename is novel with respect to the current known examples or not * @author Alexander Freytag * @date 02-05-2013 (dd-mm-yyyy) * @param _noveltyImage contains min distances of features to the current codebook * @return bool (true: class/content/... of image is novel, false: class/content/... of image is known) */ virtual bool evaluateNoveltyOfImage ( const NICE::FloatImage & _noveltyImage ) = 0; /** * @brief Hand over a previously computed codebook * @author Alexander Freytag * @date 02-05-2013 (dd-mm-yyyy) * @param _prototypes pointer to a codebook * @note we check whether we just use the pointer to the external codebook, or alternatively copy it and have it as internal codebook available lateron */ virtual void setCodebook( NICE::VVector * _prototypes); }; } // namespace #endif