/** 
* @file LFCache.h
* @brief read and write cache for local features
* @author Björn Fröhlich
* @date 02/18/2010

*/
#ifndef LFCacheINCLUDE
#define LFCacheINCLUDE

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

#include "core/basics/Config.h"
#include "LocalFeature.h"


namespace OBJREC {
	
class LFCache : public LocalFeature
{

    protected:
		//! local feature
		LocalFeature *lf;
		
		//! read/write from cachedir
		std::string cachedir;
	
		//! writing format
		int descFormat;
		
		
		int cachemode;
		
		template <class ImageClass>
		int getDescriptorsTemplate ( const ImageClass & img, NICE::VVector & positions,	NICE::VVector & descriptors ) const;

    public:
  
		/** simple constructor */
		LFCache ( const NICE::Config *conf, LocalFeature *_lf );
		
		/** simple destructor */
	
		virtual ~LFCache();
		
		/**
		* returns the size of local feature
		* @return size
		*/
		int getDescSize() const { return lf->getDescSize(); };
		
		/** 
		* get the descriptor
		* @param img input image
		* @param positions positions
		* @param descriptors output
		* @return 0
		*/
		int getDescriptors ( const NICE::Image & img, NICE::VVector & positions,	NICE::VVector & descriptors ) const;
		
		/** 
		 * get the descriptor
		 * @param cimg input color image
		 * @param positions positions
		 * @param descriptors output
		 * @return 0
		 */
		int getDescriptors ( const NICE::ColorImage & cimg, NICE::VVector & positions, NICE::VVector & descriptors ) const;
					
		void visualizeFeatures ( NICE::Image & mark,
					const NICE::VVector & positions,
					size_t color ) const;

     
};

} // namespace

#include "LFCache.tcc"

#endif
