How vector from an xml file with FileStorage Opencv API [closed]

asked 2015-07-09 12:37:20 -0500

valentine gravatar image

Hello everyone,

I am having issues read vector of matching scores from an xml file using the filestorage API in opencv c++.

When the code starts running it never stops. Just keeps ongoing. I suspect there is something wrong with an iteration somewhere but i dont know where. Here is my code for reading the scores:

void readFileNodeList(const FileNode& fn, vector<double>& result)
{
    if (fn.type() == FileNode::SEQ) {
        for (FileNodeIterator it = fn.begin(); it != fn.end();) {
            double item;
            it >> item;
            result.push_back(item);
        }
    }
}
/*Reads a vector of Matching scores from the xml file*/
void ReadScores(string filename,vector<vector<double>> Mvector){
    FileStorage fs(filename, FileStorage::READ);
    string element;
    vector<double> value;
    FileNode n = fs["score"];
    for (int i = 0; TestLabels.size(); i++){
        element = "s" + to_string(i);
        FileNode tempID = n[element];
        readFileNodeList(tempID, value);
        Mvector.push_back(value);
        value.clear();
    }
    fs.release();
}

Here is my xml file:

C:\fakepath\yxml.png

Please help.....

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2015-07-11 00:08:48.119488

Comments

Sorry guys my error. its in the condition of the for loop.

valentine gravatar imagevalentine ( 2015-07-09 12:47:06 -0500 )edit