aihot  2017-04-28 23:30:03  OpenCV |   查看评论   
const std::string&, const MyData& x)  
  • {  
  •     x.write(fs);  
  • }  
  • void read(const FileNode& node, MyData& x, const MyData& default_value = MyData()){  
  •     if(node.empty())  
  •         x = default_value;  
  •     else  
  •         x.read(node);  
  • }  
  •   
  • // 此功能将我们的自定义类打印到控制台
  • ostream& operator<<(ostream& out, const MyData& m)   
  • {   
  •     out << "{ id = " << m.id << ", ";  
  •     out << "X = " << m.X << ", ";  
  •     out << "A = " << m.A << "}";  
  •     return out;  
  • }  
  •   
  • int main(int ac, char** av)  
  • {  
  •     if (ac != 2)  
  •     {  
  •         help(av);  
  •         return 1;  
  •     }  
  •   
  •     string filename = av[1];  
  •     { //write  
  •         Mat R = Mat_<uchar>::eye(3, 3),  
  •             T = Mat_<double>::zeros(3, 1);  
  •         MyData m(1);  
  •   
  •         FileStorage fs(filename, FileStorage::WRITE);  
  •   
  •         fs << "iterationNr" << 100;  
  •         fs << "strings" << "[";                              // 文本 - 字符串序列
  •         fs << "image1.jpg" << "Awesomeness" << "baboon.jpg";  
  •         fs << "]"
  •  

    除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自OpenCV学习笔记(六)——对XML和YAML文件实现I/O操作

    留言与评论(共有 0 条评论)
       
    验证码:
    [lianlun]1[/lianlun]