Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem with PCA::read

I ran into a problem with the PCA::read() function. Saving a PCA object with PCA::write went well (I used XML format), but reading the file didn't go well:

  • First, there is no documentation* on this. I didn't find anything in the examples, neither.
  • The read/write is inconsistent. read() should also accept FileStorage as parameter.
  • Using

    FileStorage fs("pcafile.xml");["PCA"]);

    gives (!fs.empty()) exception (even if this is the node it needs).

  • copying directly the source of the read function:

    read(fs["vectors"], pca.eigenvectors);
    read(fs["values"], pca.eigenvalues);
    read(fs["mean"], pca.mean);

    reads correctly the object.

Am I doing something wrong? Anyway, I think this should be corrected in the source code.

*BTW, the documentation of OpenCV 3.x seems much worse than OpenCV 2.4. It's too concise and it doesn't contain any explanations.