cv::PCA pca(samples, cv::Mat(), cv::PCA::DATA_AS_ROW,); FileStorage fs("pca.xml",FileStorage::WRITE); pca.write(fs); fs.release(); FileStorage fs("pca.xml",FileStorage::READ); cv::PCA pca; pca.read(fs.root()); fs.release();