I know how to load/save a cv::Mat
instance into a XML-file (See this question).
我知道如何将cv :: Mat实例加载/保存到XML文件中(请参阅此问题)。
But what I really need, is to parse a std::string
(or char *
) that contains the XML, and get the cv::Mat
. Say I get the XML out of a database, and not from a file.
但我真正需要的是解析包含XML的std :: string(或char *),并获取cv :: Mat。假设我从数据库中获取XML,而不是从文件中获取XML。
Is that possible?
那可能吗?
1 个解决方案
#1
16
You can do it since OpenCV 2.4.1.
你可以从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;
#1
16
You can do it since OpenCV 2.4.1.
你可以从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;