Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

.yml file reading - complex structure

Good morning everyone,

I wish to read data from .yml file. The structer is a bit deeper than the one showed in the example: http://docs.opencv.org/3.0-rc1/d4/da4/group__core__xml.html

I'm able to read values x and y. My question is - how can I read values a and b.

Keeping same names as in the mentioned example, I have a file like this:

%YAML:1.0
features:
   -
      x: 103
      y: 166
      lbp:
         -
            a: 43
            b: 56
         -
            a: 23
            b: 87
         -
            a: 45
            b: 34
   -
      x: 115
      y: 113
      lbp:
         -
            a: 76
            b: 54
         -
            a: 42
            b: 2
         -
            a: 64
            b: 14
   -
      x: 586
      y: 12
      lbp:
         -
            a: 6
            b: 45
         -
            a: 34
            b: 34
         -
            a: 87
            b: 34

.yml file reading - complex structure

Good morning everyone,

I wish to read data from .yml file. The structer structure is a bit deeper than the one showed in the example: http://docs.opencv.org/3.0-rc1/d4/da4/group__core__xml.html

I'm able to read values x and y. My question is - how can I read values a and b.

Keeping same names as in the mentioned example, I have a file like this:

%YAML:1.0
features:
   -
      x: 103
      y: 166
      lbp:
         -
            a: 43
            b: 56
         -
            a: 23
            b: 87
         -
            a: 45
            b: 34
   -
      x: 115
      y: 113
      lbp:
         -
            a: 76
            b: 54
         -
            a: 42
            b: 2
         -
            a: 64
            b: 14
   -
      x: 586
      y: 12
      lbp:
         -
            a: 6
            b: 45
         -
            a: 34
            b: 34
         -
            a: 87
            b: 34

.yml file reading - complex structure

Good morning everyone,

I wish to read data from .yml file. The structure is a bit deeper than the one showed in the example: http://docs.opencv.org/3.0-rc1/d4/da4/group__core__xml.html

I'm able to read values x and y. My question is - how can I read values a and b.

Keeping same names as in the mentioned example, I have a file like this:

%YAML:1.0
features:
   -
      x: 103
      y: 166
      lbp:
         -
            a: 43
            b: 56
         -
            a: 23
            b: 87
         -
            a: 45
            b: 34
   -
      x: 115
      y: 113
      lbp:
         -
            a: 76
            b: 54
         -
            a: 42
            b: 2
         -
            a: 64
            b: 14
   -
      x: 586
      y: 12
      lbp:
         -
            a: 6
            b: 45
         -
            a: 34
            b: 34
         -
            a: 87
            b: 34

The code which read values x and y is:

FileStorage fs2("test.yml", FileStorage::READ);

FileNode features = fs2["features"];
FileNodeIterator it = features.begin(), it_end = features.end();
int idx = 0;
std::vector<uchar> lbpval;
// iterate through a sequence using FileNodeIterator
for( ; it != it_end; ++it, idx++ )
{
    cout << "feature #" << idx << ": ";
    cout << "x=" << (int)(*it)["x"] << ", y=" << (int)(*it)["y"];
    cout << ")" << endl;
}

fs2.release();

My question is - how can I read values a and b ?

-

.yml file reading - complex structure

Good morning everyone,

I wish to read data from .yml file. The structure is a bit deeper than the one showed in the example: http://docs.opencv.org/3.0-rc1/d4/da4/group__core__xml.html

Keeping same names as in the mentioned example, I have a file like this:

%YAML:1.0
features:
   -
      x: 103
      y: 166
      lbp:
         -
            a: 43
            b: 56
         -
            a: 23
            b: 87
         -
            a: 45
            b: 34
   -
      x: 115
      y: 113
      lbp:
         -
            a: 76
            b: 54
         -
            a: 42
            b: 2
         -
            a: 64
            b: 14
   -
      x: 586
      y: 12
      lbp:
         -
            a: 6
            b: 45
         -
            a: 34
            b: 34
         -
            a: 87
            b: 34

The code which read values x and y is:

FileStorage fs2("test.yml", FileStorage::READ);

FileNode features = fs2["features"];
FileNodeIterator it = features.begin(), it_end = features.end();
int idx = 0;
std::vector<uchar> lbpval;
// iterate through a sequence using FileNodeIterator
for( ; it != it_end; ++it, idx++ )
{
    cout << "feature #" << idx << ": ";
    cout << "x=" << (int)(*it)["x"] << ", y=" << (int)(*it)["y"];
    cout << ")" << endl;
}

fs2.release();

My question is - how can I read values a and b ?

-

.yml file reading - complex structure

Good morning everyone,

I wish to read data from .yml file. The structure is a bit deeper than the one showed in the example: http://docs.opencv.org/3.0-rc1/d4/da4/group__core__xml.html

Keeping same names as in the mentioned example, I have a file like this:

%YAML:1.0
features:
   -
      x: 103
      y: 166
      lbp:
         -
            a: 43
            b: 56
         -
            a: 23
            b: 87
         -
            a: 45
            b: 34
   -
      x: 115
      y: 113
      lbp:
         -
            a: 76
            b: 54
         -
            a: 42
            b: 2
         -
            a: 64
            b: 14
   -
      x: 586
      y: 12
      lbp:
         -
            a: 6
            b: 45
         -
            a: 34
            b: 34
         -
            a: 87
            b: 34

The code which read values x and y is:

FileStorage fs2("test.yml", FileStorage::READ);

FileNode features = fs2["features"];
FileNodeIterator it = features.begin(), it_end = features.end();
int idx = 0;
std::vector<uchar> lbpval;
 // iterate through a sequence using FileNodeIterator
for( ; it != it_end; ++it, idx++ )
{
    cout << "feature #" << idx << ": ";
    cout << "x=" << (int)(*it)["x"] << ", y=" << (int)(*it)["y"];
    cout << endl;
}

fs2.release();

My question is - how can I read values a and b ?? I know it must be simple, however I can't do that :P

-