Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello everyone.

Here is what i did to resolve this issue.

void readfeaturesFileNodeList(const FileNode& fn, vector<Mat>& result, int i){
    string element1;
    Mat feat;
    for (FileNodeIterator current = fn.begin(); current != fn.end();current++){
        element1 = "f" + to_string(i);
        FileNode rt = *current;
        rt[element1]>> feat;
        result.push_back(feat);
    }
}

and the second function is given below.

void ReadGlobalFeatures(string filename,vector<Mat>& Fvector){
    FileStorage fs(filename, FileStorage::READ);
    Mat feat;
    vector<Mat> vfeat;
    string element;
    string element1;
    FileNode k = fs.root();

    for (int i = 0; i <TrainLabels.size(); i++){
        //element1 = "f" + to_string(i);
        FileNode tempID = k;
        readfeaturesFileNodeList(tempID, vfeat,i);
    }
    Fvector = vfeat;
    fs.release();
}

Thanks berak and all who contributed to this i am really grateful. This is truly the best opencv forum and i have learnt from all you.