Auxilliary Tool:
A purely virtual class for providing the skeleton for specific features. This allows different features to be manipulated using a common set of tools.
More...
#include <Feature.h>
Public Member Functions | |
virtual double | evaluateImagePatch (const ImagePatch *patch)=0 |
Turn an ImagePatch into a scalar value. This is the basic job of any feature. Must be overridden in derived classes. | |
virtual double | evaluateImagePatch (const ImagePatch &patch) |
Turn an ImagePatch into a scalar value. This is the basic job of any feature. | |
virtual void | filterPatchList (PatchList *patches)=0 |
Apply the feature to a PatchList data structure. Must be overridden in derived classes. | |
virtual void | setFeatureParameters (const cv::Mat ¶mVec)=0 |
Basic feature initialization. Must be overridden in derived classes. | |
virtual std::vector< Feature * > | getSimilarFeatures (int numFeatures=1) |
Get features similar to the current feature. This is useful for searching through feature space for local optima. | |
virtual void | getFeatureVisualization (cv::Mat &dest) |
Get a nice visual representation of the feature. | |
virtual std::string | debugInfo () const |
Prints information about this feature for help debugging. By default, this prints the feature type, and its parameters. | |
virtual | ~Feature () |
Destructor. By default, this cleans up the parameters, valid parameter ranges, kernel image, and name. Subclasses are responsible for cleaning up extra memory. | |
Feature * | getFeatureOfSameTypeAndSize () const |
Get a feature with same type / dimension as this one, but random parameters. | |
Feature * | copy () const |
Get a feature with the same type / dimension / parameters as this one. | |
void | evaluateImagePatches (const std::vector< ImagePatch * > &imagePatches, std::vector< double > &scalarVals) |
Apply feature to multiple ImagePatch objects. | |
void | evaluateImagePatches (const std::vector< ImagePatch > &imagePatches, std::vector< double > &scalarVals) |
Apply feature to multiple ImagePatch objects. | |
void | evaluateImagePatches (const std::vector< ImagePatch * > &imagePatches, cv::Mat &scalarVals) |
Apply feature to multiple ImagePatch objects. | |
void | evaluateImagePatches (const std::vector< ImagePatch > &imagePatches, cv::Mat &scalarVals) |
Apply feature to multiple ImagePatch objects. | |
cv::Size | getPatchSize () const |
Get the size of patch that is "natural" for this feature. | |
Static Public Member Functions | |
static Feature * | getFeatureOfType (std::string featureName, cv::Size patchSize) |
Get a subclass based on its name. If you subclass Feature, you are responsible for modifying Feature.cpp to make this function aware of your feature. This function is important for saving the state of features for classifiers. | |
Friends | |
std::ostream & | operator<< (std::ostream &ofs, Feature *feat) |
Write to a file. | |
std::istream & | operator>> (std::istream &ifs, Feature *&feat) |
Read from a file. |
Auxilliary Tool:
A purely virtual class for providing the skeleton for specific features. This allows different features to be manipulated using a common set of tools.
In general, we conceive of a feature as something that takes an image patch as input, and produces a scalar output. It may be necessary at times for a feature to apply itself efficiently to multiple image patches, using the PatchList data structure. Also, it will be necessary to find features similar to this one, and may be convenient to represent a feature in a compact parameterized form. Thus, a feature should implement the following:
virtual double evaluateImagePatch(const ImagePatch* patch); virtual void filterPatchList( PatchList* patches); virtual void setFeatureParameters(const CvMat* paramVec);
Additionally, the following utilities are provided but may be overridden:
virtual vector<Feature*> getSimilarFeatures(int numFeatures); virtual IplImage* visualizeFeature(); virtual string debugInfo() const; virtual ~Feature();
NOTE ON SUBCLASSING: In order for everything to work properly, a few rules need to be followed. First, subclasses should be able to completely reinitialize their own member variables from their parameter vector. This allows us to save a parameter vector to disk and then reconstruct the feature later. Second, subclasses should set the protected "featureName" variable, which helps determine which what the actual type of a saved feature is. Third (finally), Feature.cpp's getFeatureOfType method must be modified to be aware of your feature class, by calling the correct constructor (your constructor) when a feature of your type is read from disk.
Feature * Feature::copy | ( | ) | const |
Get a feature with the same type / dimension / parameters as this one.
string Feature::debugInfo | ( | ) | const [virtual] |
Prints information about this feature for help debugging. By default, this prints the feature type, and its parameters.
double Feature::evaluateImagePatch | ( | const ImagePatch & | patch ) | [virtual] |
Turn an ImagePatch into a scalar value. This is the basic job of any feature.
patch | The image patch to evaluate. |
virtual double Feature::evaluateImagePatch | ( | const ImagePatch * | patch ) | [pure virtual] |
Turn an ImagePatch into a scalar value. This is the basic job of any feature. Must be overridden in derived classes.
patch | The image patch to evaluate. |
Implemented in BoxFeature.
void Feature::evaluateImagePatches | ( | const std::vector< ImagePatch * > & | imagePatches, |
cv::Mat & | scalarVals | ||
) |
Apply feature to multiple ImagePatch objects.
imagePatches | Patches to evaluate. |
scalarVals | Result of evaluation, in a CvMat data structure. If the provided CvMat is NULL or has inappropriate size, it will be freed and recreated. |
void Feature::evaluateImagePatches | ( | const std::vector< ImagePatch > & | imagePatches, |
cv::Mat & | scalarVals | ||
) |
Apply feature to multiple ImagePatch objects.
imagePatches | Patches to evaluate. |
scalarVals | Result of evaluation, in a CvMat data structure. If the provided CvMat is NULL or has inappropriate size, it will be freed and recreated. |
void Feature::evaluateImagePatches | ( | const std::vector< ImagePatch * > & | imagePatches, |
std::vector< double > & | scalarVals | ||
) |
Apply feature to multiple ImagePatch objects.
imagePatches | Patches to evaluate. |
scalarVals | Result of evaluation, in an STL vector data structure. |
void Feature::evaluateImagePatches | ( | const std::vector< ImagePatch > & | imagePatches, |
std::vector< double > & | scalarVals | ||
) |
Apply feature to multiple ImagePatch objects.
imagePatches | Patches to evaluate. |
scalarVals | Result of evaluation, in an STL vector data structure. |
virtual void Feature::filterPatchList | ( | PatchList * | patches ) | [pure virtual] |
Apply the feature to a PatchList data structure. Must be overridden in derived classes.
This is very important for efficiently filtering a whole image. The data for the filtering operation as well as the destination are contained in that data structure. See PatchList.h for details.
patches | Remaining patches in a large image to be filtered. |
Implemented in BoxFeature.
Feature * Feature::getFeatureOfSameTypeAndSize | ( | ) | const |
Get a feature with same type / dimension as this one, but random parameters.
static Feature* Feature::getFeatureOfType | ( | std::string | featureName, |
cv::Size | patchSize | ||
) | [static] |
virtual void Feature::getFeatureVisualization | ( | cv::Mat & | dest ) | [virtual] |
Get a nice visual representation of the feature.
By default, this simply returns the "kernel" protected member variable, which subclasses should set during "setFeatureParameters".
Size Feature::getPatchSize | ( | ) | const |
Get the size of patch that is "natural" for this feature.
Generally, features have a basic size. For example, a convolution-based feature has the size of the convolution kernel. Asking the feature to filter an ImagePatch that does not match this size may result in degraded performance.
vector< Feature * > Feature::getSimilarFeatures | ( | int | numFeatures = 1 ) |
[virtual] |
Get features similar to the current feature. This is useful for searching through feature space for local optima.
By default, this randomly mutates the elements of the feature parameter vector. Override this function if different behavior is desired.
numFeatures | Number of nearby features to grab. |
virtual void Feature::setFeatureParameters | ( | const cv::Mat & | paramVec ) | [pure virtual] |
Basic feature initialization. Must be overridden in derived classes.
Subclasses should be able to completely reinitialize their own member variables from their parameter vector. This allows us to save a parameter vector to disk and then reconstruct the feature later.
paramVec | A set of values sufficient to reconstruct a feature, or to construct a new one automatically. Must have type CV_64FC1 |
Implemented in BoxFeature, and HaarFeature.