在OpenCV中读取YAML中的垫点

时间:2016-06-09 05:54:38

标签: c++ xml opencv file-io yaml

我正在尝试从YAML文件中读取矩阵,但它没有显示任何输出。 以下是cpp代码。

int main()
{
    string filename = "test.yml";
    cout << endl << "Reading: " << endl;
    FileStorage fs;
    fs.open(filename, FileStorage::READ);

    Mat matPts;
    fs["matPts"] >> matPts;                                                                  
    cout << endl
        << "matPts = " << matPts << endl;    
return 0;

}

YAML文件看起来像这样

%YAML:1.0
version: 3
frame0region0:
   numPts: 2
   matPts: !!opencv-matrix
      rows: 2
      cols: 2
      dt: i
      data: [ 528, 93, 563, 128 ]
   attribute: head
frame0region1:
   numPts: 2
   matPts: !!opencv-matrix
      rows: 2
      cols: 2
      dt: i
      data: [ 629, 101, 671, 143 ]
   attribute: head
frame0region2:
   numPts: 2
   matPts: !!opencv-matrix
      rows: 2
      cols: 2
      dt: i
      data: [ 1114, 368, 1187, 446 ]
   attribute: head
frame0numValidRegions: 3

我想存储矩阵,框架号和区域号,然后将其写入另一个xml或不同结构的文本文件中。

0 个答案:

没有答案