/** 
* @file FCFPFeature.cpp
* @author Erik Rodner
* @date 11/15/2007

*/
#include <iostream>
#include <core/imagedisplay/ImageDisplay.h>
#include "FCFPFeature.h"
#include "vislearning/cbaselib/FeaturePool.h"
#include "vislearning/baselib/ICETools.h"

using namespace OBJREC;

using namespace std;

using namespace NICE;



FCFPFeature::FCFPFeature( const Config * conf ) : 
    FeatureFactory ( conf ), imgf (conf, "FCFPFeature" )
{
}

FCFPFeature::~FCFPFeature()
{
}

int FCFPFeature::convertRGB ( const NICE::ColorImage & img, NICE::Vector & vec )
{
    FeaturePool fpool;

    imgf.fillFeaturePool ( fpool, false );
    vec.resize ( fpool.size() );

    CachedExample ce ( img );
    Example example ( &ce ); 

    imgf.fillExample ( example.ce );

    fprintf (stderr, "Total size of feature vector will be: %d\n", fpool.size() );
    uint index = 0;
    for ( FeaturePool::const_iterator i = fpool.begin();
				      i != fpool.end();
				      i++, index++ )
    {
	Feature *f = i->second;
	vec[index] = f->val ( &example );
    }

    example.clean();
    fpool.destroy();

    return 0;
}

int FCFPFeature::convert ( const NICE::Image & img, NICE::Vector & vec )
{
    FeaturePool fpool;
    imgf.fillFeaturePool ( fpool, false );
    
    vec.resize ( fpool.size() );

    CachedExample ce ( img );
    Example example ( &ce ); 

    imgf.fillExample ( example.ce );

    fprintf (stderr, "Total size of feature std::vector will be: %d\n", fpool.size() );
    uint index = 0;
    for ( FeaturePool::const_iterator i = fpool.begin();
				      i != fpool.end();
				      i++, index++ )
    {
	Feature *f = i->second;
	vec[index] = f->val ( &example );
    }

    // do not clean this stuff: example.clean();
    fpool.destroy();

    return 0;
}
