Update pca.cpp
This commit is contained in:
parent
1cd3c6f364
commit
c6e6d4c822
@ -2316,11 +2316,11 @@ public:
|
||||
The operator performs %PCA of the supplied dataset. It is safe to reuse
|
||||
the same PCA structure for multiple datasets. That is, if the structure
|
||||
has been previously used with another dataset, the existing internal
|
||||
data is reclaimed and the new eigenvalues, @ref eigenvectors , and @ref
|
||||
data is reclaimed and the new @ref eigenvalues, @ref eigenvectors and @ref
|
||||
mean are allocated and computed.
|
||||
|
||||
The computed eigenvalues are sorted from the largest to the smallest and
|
||||
the corresponding eigenvectors are stored as eigenvectors rows.
|
||||
The computed @ref eigenvalues are sorted from the largest to the smallest and
|
||||
the corresponding @ref eigenvectors are stored as eigenvectors rows.
|
||||
|
||||
@param data input samples stored as the matrix rows or as the matrix
|
||||
columns.
|
||||
@ -2400,11 +2400,17 @@ public:
|
||||
*/
|
||||
void backProject(InputArray vec, OutputArray result) const;
|
||||
|
||||
/** @brief write and load PCA matrix
|
||||
/** @brief write PCA objects
|
||||
|
||||
*/
|
||||
void write(FileStorage& fs ) const;
|
||||
void read(const FileNode& fs);
|
||||
Writes @ref eigenvalues @ref eigenvectors and @ref mean to specified FileStorage
|
||||
*/
|
||||
void write(FileStorage& fs) const;
|
||||
|
||||
/** @brief load PCA objects
|
||||
|
||||
Loads @ref eigenvalues @ref eigenvectors and @ref mean from specified FileNode
|
||||
*/
|
||||
void read(const FileNode& fn);
|
||||
|
||||
Mat eigenvectors; //!< eigenvectors of the covariation matrix
|
||||
Mat eigenvalues; //!< eigenvalues of the covariation matrix
|
||||
|
@ -158,15 +158,14 @@ void PCA::write(FileStorage& fs ) const
|
||||
fs << "mean" << mean;
|
||||
}
|
||||
|
||||
void PCA::read(const FileNode& fs)
|
||||
void PCA::read(const FileNode& fn)
|
||||
{
|
||||
CV_Assert( !fs.empty() );
|
||||
String name = (String)fs["name"];
|
||||
CV_Assert( name == "PCA" );
|
||||
CV_Assert( !fn.empty() );
|
||||
CV_Assert( (String)fn["name"] == "PCA" );
|
||||
|
||||
cv::read(fs["vectors"], eigenvectors);
|
||||
cv::read(fs["values"], eigenvalues);
|
||||
cv::read(fs["mean"], mean);
|
||||
cv::read(fn["vectors"], eigenvectors);
|
||||
cv::read(fn["values"], eigenvalues);
|
||||
cv::read(fn["mean"], mean);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
Loading…
x
Reference in New Issue
Block a user