#include "vislearning/features/localfeatures/LFCache.h"

#include <iostream>

#include "vislearning/features/localfeatures/sift.h"

#include "vislearning/baselib/Globals.h"
#include "core/basics/StringTools.h"

using namespace OBJREC;

using namespace std;
using namespace NICE;



LFCache::LFCache( const Config *conf, LocalFeature *_lf ):lf(_lf)
{
	cachedir = conf->gS("cache", "root");
	cachemode = Globals::getCacheMode ( conf->gS("cache", "mode", "cat") );
    
	std::string descFormat_s = conf->gS("cache", "descriptor_format", "binary_double");
	
	if ( descFormat_s == "binary_double" )
		descFormat = VVector::FILEFORMAT_BINARY_DOUBLE;
	else if ( descFormat_s == "binary_uchar" )
		descFormat = VVector::FILEFORMAT_BINARY_CHAR;
	else if ( descFormat_s == "text_line" )
		descFormat = VVector::FILEFORMAT_LINE;
	else if ( descFormat_s == "text_ice" )
		descFormat = VVector::FILEFORMAT_NICE;
}

LFCache::~LFCache()
{
}

int LFCache::getDescriptors ( const NICE::Image & img, VVector & positions, VVector & descriptors ) const
{
	return getDescriptorsTemplate<NICE::Image> ( img, positions, descriptors );
}

int LFCache::getDescriptors ( const NICE::ColorImage & cimg, VVector & positions, VVector & descriptors ) const
{
	return getDescriptorsTemplate<NICE::ColorImage>(cimg, positions, descriptors );
}

void LFCache::visualizeFeatures ( NICE::Image & mark, const VVector & positions, size_t color ) const
{
	lf->visualizeFeatures(mark, positions, color);
}

