/** 
* @file LFWriteCache.h
* @brief Write local features to file (whenever a descriptor is computed, it will be checked whether a corresponding file already exists. If not, we save the descriptor)
* @author Erik Rodner, Alexander Freytag
* @date 02/14/2008

*/
#ifndef LFWriteCacheINCLUDE
#define LFWriteCacheINCLUDE

#include "core/vector/VectorT.h"
#include "core/vector/MatrixT.h"
#include "core/image/ImageT.h"
 
#include "LocalFeatureRepresentation.h"
#include "core/basics/Config.h"


namespace OBJREC {

  /** @class LFWriteCache
  * @brief Write local features to file (whenever a descriptor is computed, it will be checked whether a corresponding file already exists. If not, we save the descriptor)
  *
  */  
  class LFWriteCache : public LocalFeatureRepresentation
  {

      protected:
        const LocalFeatureRepresentation *lfrep;

        std::string cachedir;

        int descFormat;
        int cachemode;


      public:
    
        /** simple constructor */
        LFWriteCache( const NICE::Config *conf, 
            const LocalFeatureRepresentation *lfrep,
            const std::string & _section = "cache"
                    ); 
        
        /** simple destructor */
        virtual ~LFWriteCache();
      
        int getDescSize () const;
      
        /**
        * extract features for gray images
        * @param img input image
        * @param features output features
        * @param positions position of the features
        * @return 
        */
        int extractFeatures ( const NICE::Image & img, 
              NICE::VVector & features, 
              NICE::VVector & positions ) const;
        
        /**
        * extract features for color images
        * @param img input image
        * @param features output features
        * @param positions position of the features
        * @return 
        */
        int extractFeatures ( const NICE::ColorImage & img, 
              NICE::VVector & features, 
              NICE::VVector & positions ) const;
      
        void visualize ( NICE::Image & img, 
          const NICE::Vector & feature ) const;
      
        void visualizeFeatures ( NICE::Image & mark,
              const NICE::VVector & positions,
              size_t color ) const;
  };


} // namespace

#endif
