123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- /**
- * @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 <core/vector/Distance.h>
- #include <core/vector/VVector.h>
- // vislearning
- #include <vislearning/cbaselib/MultiDataset.h>
- //
- #include <vislearning/features/localfeatures/GenericLocalFeatureSelection.h>
- //
- #include <vislearning/math/cluster/ClusterAlgorithm.h>
- 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<double> * 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
|