Ask Your Question

Problem with PCA::read

asked 2016-01-26 11:14:46 -0500

kbarni gravatar image

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-04-12 10:51:06 -0500

mshabunin gravatar image

You should load PCA from root node:

edit flag offensive delete link more

Question Tools



Asked: 2016-01-26 11:14:46 -0500

Seen: 505 times

Last updated: Apr 12 '16