提交 c6e6d4c8 编写于 作者: S Suleyman TURKMEN

Update pca.cpp

上级 1cd3c6f3
......@@ -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>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册