Ask Your Question
1

Problem with PCA::read

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

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.read(fs["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
1

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

mshabunin gravatar image

You should load PCA from root node: pca.read(fs.root())

edit flag offensive delete link more

Question Tools

2 followers

Stats

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

Seen: 821 times

Last updated: Apr 12 '16