Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

How to read a Matrix from a child node with FileStorage API

$
0
0
Hello guys, I am having a little issue here. I saved a couple of mat as child nodes in xml using the Filestorage API in opencv. However when i try to read them back the filestorage API reads the same values which are wrong for all the Matrices in the xml file. I don't know where am getting it wrong. please help. Here is my code for writing and reading. FileStorage file(filename, FileStorage::WRITE); file << "Features" << "{"; for (int i = 0; i < TrainFeatureVector.size(); i++){ string element1 = "f" + to_string(i); file << element1 << TrainFeatureVector[i]; } file << "}" FileStorage fs(filename, FileStorage::READ); Mat feat; string element; string element1; FileNode k = fs["Features"]; for (int i = 0; i < k.size(); i++){ element1 = "f" + to_string(i); k[element1] >> feat; Fvector.push_back(feat);} Here is my xml file [C:\fakepath\sxml.png](/upfiles/14367160237383741.png)

Viewing all articles
Browse latest Browse all 41027


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>