if (n.type() != FileNode::SEQ)
{
cerr << "字符串不是序列! 失败" << endl;
return 1;
}
FileNodeIterator it = n.begin(), it_end = n.end(); // 通过节点
for (; it != it_end; ++it)
cout << (string)*it << endl;
n = fs["Mapping"]; // 从序列中读取映射
cout << "Two " << (int)(n["Two"]) << "; ";
cout << "One " << (int)(n["One"]) << endl << endl;
MyData m;
Mat R, T;
fs["R"] >> R; // 读cv::Mat
fs["T"] >> T;
fs["MyData"] >> m; // 阅读你自己的结构
cout << endl
<< "R = " << R << endl;
cout << "T = " << T << endl << endl;
cout << "MyData = " << endl << m << endl << endl;
// 显示非现有节点的默认行为
cout << "尝试读取NonExisting(应初始化其默认值的数据结构).";
fs["NonExisting"] >> m;
cout << endl << "NonExisting = " << endl << m << endl;
}