/** 
* @file FCBagSift.cpp
* @brief Feature Factory for Bag of SIFT Features
* @author Erik Rodner
* @date 10/25/2007

*/
#include <iostream>

#include "vislearning/math/cluster/GSCluster.h"

#include "vislearning/features/simplefeatures/FCBagSift.h"

using namespace OBJREC;

using namespace std;
// refactor-nice.pl: check this substitution
// old: using namespace ice;
using namespace NICE;

#define DEBUG_SIFTLOCATIONS

FCBagSift::FCBagSift( const Config * conf, 
		      const LocalFeatureRepresentation *_lfrep ) 
    : FeatureFactory ( conf ), lfrep(_lfrep)
{
    gs = new GSCluster ( conf );
}

FCBagSift::~FCBagSift()
{
    delete gs;
}

int FCBagSift::convert ( const NICE::Image & img, NICE::Vector & vec )
{
    VVector features;
    VVector positions;

    lfrep->extractFeatures ( img, features, positions );

    if ( features.size() <= 0 ) return -1;
    
    gs->signature ( features, vec );

    return 0;
}