25 #ifndef _FEATURE_GENERATOR_H
26 #define _FEATURE_GENERATOR_H
35 template<
class Feature>
49 virtual unsigned int Count()
const = 0;
51 virtual bool Next(Feature & out) = 0;
53 virtual void Reset() = 0;
63 std::vector<bool> sampled;
66 std::cerr <<
"Error: too few features" << std::endl;
73 out.push_back( in[ nrand(in.size() ) ] );
78 template<
class FeatureGenerator>
88 std::cout <<
"Generating feature from " << generator.Feature() <<
" haar bases..." << std::endl;
94 while(generator.
Next(h) ) {
96 features.push_back(h);
99 if((count & (4096-1))==0)
105 std::cout << count <<
" feature generated in " << t.GetTime() <<
"s. Keeped " << features.size() <<
"\n";
111 template<
class TFeature>
113 typename std::vector<TFeature>::const_iterator i;
117 std::vector<TFeature> features;
123 typedef TFeature FeatureType;
134 i = features.begin();
136 bool Next(TFeature & out)
138 if (i==features.end())
return false;
Feature FeatureType
The feature type generate by this generator.
Definition: FeatureGenerator.h:41
bool RandomSampleFeature(std::vector< T > &out, const std::vector< T > &in, int n)
Definition: FeatureGenerator.h:61
virtual void Reset()=0
reset any interal counters
unsigned int Feature() const
number of bases (cosmetic)
Definition: FeatureGenerator.h:131
Definition: FeatureGenerator.h:36
This generator uses a stored feature list.
Definition: FeatureGenerator.h:112
Cross Platform High Performance timer.
void GenerateFeatures(std::vector< typename FeatureGenerator::FeatureType > &features, FeatureGenerator &generator)
Fill vector of FeatureType using a FeatureGenerator object.
Definition: FeatureGenerator.h:79
virtual bool CanBePrecomputed() const
Test if the feature generator can be precomputed. In this case Count must be valid.
Definition: FeatureGenerator.h:47
virtual bool Next(Feature &out)=0
return the next feature, or return false
int n_bases
only for cosmetic
Definition: FeatureGenerator.h:119
some methods about random number generation
virtual unsigned int Count() const =0
return the count of feature available