Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you should be able to keep your reading code, if you change the writing code to:

void writeVector(cv::FileStorage &fs, std::vector<std::string> &names, std::vector<CenterValues> &data)
{

    fs << "features" << "[";
    for (int i = 0; i < data.size(); i++)
    {
        fs <<"{:"<< names[0] << i<<names[1] << data[i].lightValue <<names[2] << data[i].aValue<<names[3] << data[i].bValue << names[4] << data[i].xValue<<names[5] << data[i].yValue<<names[6] << data[i].depthValue<<"}";
    }
    fs << "]";
}

this will write xml similar to:

<?xml version="1.0"?>
<opencv_storage>
<features>
  <_><SuperPixelno>0</SuperPixelno>
    <lValue>1.</lValue>
    <aValue>2.</aValue>
    <bValue>3.</bValue>
    <xCenter>4.</xCenter>
    <yCenter>5.</yCenter>
    <depthValue>0.</depthValue></_>
  <_><SuperPixelno>1</SuperPixelno>
    <lValue>5.</lValue>
    <aValue>6.</aValue>
    <bValue>7.</bValue>
    <xCenter>8.</xCenter>
    <yCenter>9.</yCenter>
    <depthValue>0.</depthValue></_>
 ...