【问题标题】:How to save Matrix<float> to XML file?如何将 Matrix<float> 保存到 XML 文件?
【发布时间】:2012-05-17 09:45:38
【问题描述】:

我正在尝试在 C# 中使用 emguCV 的 SURF 特征检测器来检测图像的关键点。 我正在使用此代码:

Image<Gray, Byte> myImage = new Image<Gray, byte>("test.png");
SURFDetector surf = new SURFDetector(500, false);
VectorOfKeyPoint myKeyPoints = surf.DetectKeyPointsRaw(myImage, null);
Matrix<float> myDescriptors = surf.ComputeDescriptorsRaw(myImage, null, myKeyPoints);

所以我掌握了该矩阵中的关键点。我想要做的是将这些关键点保存/导出到 .xml 文件中。 有人可以帮助我如何做到这一点吗?提前致谢。

【问题讨论】:

  • 给定的答案有效吗?

标签: c# xml matrix emgucv surf


【解决方案1】:

你可以用 XxmlSerializer 和 StringBuilder 做到这一点

String filePath = "";
StringBuilder sb = new StringBuilder();
(new XmlSerializer(typeof(Matrix<float>))).Serialize(new StringWriter(sb), modelDescriptors); 

System.IO.File.WriteAllText(filePath , sb.ToString());

参考:

http://www.emgu.com/wiki/index.php/Working_with_Matrices

【讨论】:

    猜你喜欢
    • 2015-07-23
    • 1970-01-01
    • 2011-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-13
    相关资源
    最近更新 更多