>

2014년 4월 25일 금요일

How to read/write a PCA object from/to a cv::FileStorage

Following is a fixed version of http://answers.opencv.org/question/4899/how-to-readwrite-a-pca-object-fromto-a



void save(const string file_name, cv::PCA &pca_)
{
    cv::FileStorage fs(file_name, cv::FileStorage::WRITE);
    fs << "mean" << pca_.mean;
    fs << "e_vectors" << pca_.eigenvectors;
    fs << "e_values" << pca_.eigenvalues;
    fs.release();
}

void load(const string file_name,cv::PCA &pca_)
{
    cv::FileStorage fs(file_name,cv::FileStorage::READ);
    fs["mean"] >> pca_.mean ;
    fs["e_vectors"] >> pca_.eigenvectors ;
    fs["e_values"] >> pca_.eigenvalues ;
    fs.release();
}

댓글 없음:

댓글 쓰기