gpt4 book ai didi

c++ - OpenCV C++ : How to write a list of string in xml file using OpenCV FileStorage?

转载 作者:太空宇宙 更新时间:2023-11-03 22:46:46 27 4
gpt4 key购买 nike

我想使用 Opencv 的 FileStorage 创建一个包含图像字符串路径列表的 xml 文件,如下所示:

<?xml version="1.0"?>
<opencv_storage>
<imagelist>
image1.png
image2.png
image3.png
image4.png
image5.png
image6.png
</imagelist>
</opencv_storage>

我找到了很多解决方案来使用 FileNode 读取这个文件,事件发生在 docs.opencv.org 上而且我没有看到如何创建这样的文件。

如有任何帮助,我们将不胜感激。

最佳答案

根据您发布的链接,我们有以下说明:

Input/Output of vectors (arrays) and associative maps. As I mentioned beforehand, we can output maps and sequences (array, vector) too. Again we first print the name of the variable and then we have to specify if our output is either a sequence or map.

For sequence before the first element print the [ character and after the last one the ] character:

fs << "strings" << "[";     // text - string sequence
fs << "image1.jpg" << "Awesomeness" << "baboon.jpg";
fs << "]";

For maps the drill is the same however now we use the { and } delimiter characters:

fs << "Mapping";   // text - mapping
fs << "{" << "One" << 1;
fs << "Two" << 2 << "}";

您可以根据需要使用这些说明(如果您想将其放在一个字符串中,或​​者从每个文件中创建一个字段...

关于c++ - OpenCV C++ : How to write a list of string in xml file using OpenCV FileStorage?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45862742/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com