How can I read from an XML-string in OpenCV?

前端 未结 1 1045
猫巷女王i
猫巷女王i 2021-02-07 22:09

I know how to load/save a cv::Mat instance into a XML-file (See this question).

But what I really need, is to parse a std::string (or cha

1条回答
  •  孤独总比滥情好
    2021-02-07 22:47

    You can do it since OpenCV 2.4.1.

    Here is a code sample from release notes:

    //==== storing data ====
    FileStorage fs(".xml", FileStorage::WRITE + FileStorage::MEMORY);
    fs << "date" << date_string << "mymatrix" << mymatrix;
    string buf = fs.releaseAndGetString();
    
    //==== reading it back ====
    FileStorage fs(buf, FileStorage::READ + FileStorage::MEMORY);
    fs["date"] >> date_string;
    fs["mymatrix"] >> mymatrix;
    

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