How should a typical .yml or .xml matrix look for OpenCV use

后端 未结 1 1090

I need to specify a matrix inside a file and then load it onto OpenCV as a Mat for further processing. How can the cols and lines be specified and where do elements

相关标签:
1条回答
  • 2021-01-28 04:09

    Read/Write any OpenCV data structure to or from .xml / .yaml file is very simple.

    Before you write any content to such file you need to open it and at the end to close it. The XML/YAML data structure in OpenCV is FileStorage.

    string filename = "I.xml";
    FileStorage fs(filename, FileStorage::WRITE);
    
    Mat R = Mat_<uchar >::eye (3, 3),
    
    fs << "R" << R; // Write entire cv::Mat
    fs["R"] >> R;   // Read entire cv::Mat
    

    Check out this link File Input and Output using XML and YAML files

    0 讨论(0)
提交回复
热议问题