[英]Reading nested XML in OpenCV
這個stackoverflow問題回答了如何通過嵌套將數據寫入XML文件: 在OpenCV中創建XML文件
參考相同的問題(和可接受的答案),我將如何使用FileStorage類讀取相同的文件?
簡而言之,如何讀取以下代碼段寫入的數據?
FileStorage fs; // Open it and check that it is opened;
fs << "SimpleData" << 1;
fs << "Structure" << "{";
fs << "firstField" << 1;
fs << "secondField" << 2;
fs << "}"; // End of structure node
fs << "SimpleData2" << 2;
您可以使用:
FileStorage fs;
fs.open(filename, FileStorage::READ);
int SimpleData = (int) fs["SimpleData"];
FileNode n = fs["Structure"]; // Read Structure sequence - Get node
int firstField = (int)(n["firstField"]);
int secondField = (int)(n["secondField"]);
int SimpleData2 = (int) fs["SimpleData2"];
在此處查看更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.