Created
December 28, 2018 18:51
-
-
Save berak/f728d3ebc3d0c9dd5dc480dfa5f99768 to your computer and use it in GitHub Desktop.
LDA wrapped (minimally) to python/java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CV_EXPORTS_W LDA | |
{ | |
public: | |
/** @brief constructor | |
Initializes a LDA with num_components (default 0). | |
*/ | |
explicit LDA(int num_components = 0); | |
/** Initializes and performs a Discriminant Analysis with Fisher's | |
Optimization Criterion on given data in src and corresponding labels | |
in labels. If 0 (or less) number of components are given, they are | |
automatically determined for given data in computation. | |
*/ | |
CV_WRAP LDA(InputArrayOfArrays src, InputArray labels, int num_components = 0); | |
/** Serializes this object to a given filename. | |
*/ | |
CV_WRAP void save(const String& filename) const; | |
/** Deserializes this object from a given filename. | |
*/ | |
CV_WRAP void load(const String& filename); | |
/** Serializes this object to a given cv::FileStorage. | |
*/ | |
void save(FileStorage& fs) const; | |
/** Deserializes this object from a given cv::FileStorage. | |
*/ | |
void load(const FileStorage& node); | |
/** destructor | |
*/ | |
~LDA(); | |
/** Compute the discriminants for data in src (row aligned) and labels. | |
*/ | |
void compute(InputArrayOfArrays src, InputArray labels); | |
/** Projects samples into the LDA subspace. | |
src may be one or more row aligned samples. | |
*/ | |
CV_WRAP Mat project(InputArray src); | |
/** Reconstructs projections from the LDA subspace. | |
src may be one or more row aligned projections. | |
*/ | |
Mat reconstruct(InputArray src); | |
/** Returns the eigenvectors of this LDA. | |
*/ | |
Mat eigenvectors() const { return _eigenvectors; } | |
/** Returns the eigenvalues of this LDA. | |
*/ | |
Mat eigenvalues() const { return _eigenvalues; } | |
static Mat subspaceProject(InputArray W, InputArray mean, InputArray src); | |
static Mat subspaceReconstruct(InputArray W, InputArray mean, InputArray src); | |
protected: | |
int _num_components; | |
Mat _eigenvectors; | |
Mat _eigenvalues; | |
void lda(InputArrayOfArrays src, InputArray labels); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment