From c6e6d4c822d69e42aa7ae13e46075c545e46f03e Mon Sep 17 00:00:00 2001 From: Suleyman TURKMEN Date: Tue, 26 Jan 2016 23:56:25 +0200 Subject: [PATCH] Update pca.cpp --- modules/core/include/opencv2/core.hpp | 20 +++++++++++++------- modules/core/src/pca.cpp | 13 ++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 559226079b..ca4ad75698 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -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 diff --git a/modules/core/src/pca.cpp b/modules/core/src/pca.cpp index 85ba443245..f8730475f6 100644 --- a/modules/core/src/pca.cpp +++ b/modules/core/src/pca.cpp @@ -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