[英]How do I access elements of a yml file in opencv?
我有一個yml文件,看起來像這樣:
%YAML:1.0
X: !!opencv-matrix
rows: 13
cols: 40
dt: f
data: [ 166.000000, 162.666667, 159.333333,
156.000000, 152.666667, 149.333333, 146.000000,
142.333333, 138.666667, 135.000000, 131.333333,.... etc
如何將該文件轉換為矩陣形式並訪問其元素。 我必須對該矩陣進行一些數學運算。 我已經編寫了以下代碼來讀取此文件。 如果我想說第二列減去第一列怎么辦? 請幫忙。
碼:
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
using namespace cv;
using namespace std;
int main (int argc, char * const argv[])
{
Mat X;
string XFile = "newStorageFile.yml";
FileStorage fsDemoX(XFile , FileStorage::READ);
fsDemoX["X"] >> X;
cout << "Print the contents of X:" << endl;
cout << X << endl << endl;
fsDemoX.release();
return 0;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.