对于C#,使用EMGUCV可以将Matrix保存为XML,以便以后读取。
由于VectorOfKeyPoint是可序列化的类,因此它也可以保存到XML文件。
但是,当它打开时,此UnmanagedObject VectorOfKeyPoint为空,无法使用。

是否可以通过这种方式做一些事情,即从XML加载VectorOfKeyPoint并以相同的方式使用它?

如今,工作代码(如EMGU Wiki中所述)已更改为VectorOfKeyPoint:

Parsing from/to XML

最佳答案

终于能够做到了。

除了可以序列化VectorOfKeyPoint本身(不起作用)之外,还可以序列化其点。

例如。

序列化:

VectorOfKeyPoint vectorOfKeyPoints = new VectorOfKeyPoint();
StringBuilder sb = new StringBuilder();
MKeyPoint[] keyPoints = vectorOfKeyPoints.ToArray();
(new XmlSerializer(typeof(MKeyPoint[]))).Serialize(new StringWriter(sb), keyPoints);
xmlKeyPoints = sb.ToString();

反序列化:
XmlReader xmlReader = XmlReader.Create(new StringReader(xmlStr));
MKeyPoint[] arrayOfKeyPoints = (MKeyPoint[])(new XmlSerializer(typeof(MKeyPoint[]))).Deserialize(xmlReader);
VectorOfKeyPoint vectorOfKeyPoints = new VectorOfKeyPoint();
vectorOfKeyPoints.Push(arrayOfKeyPoints);

关于c# - 将EMGUCV VectorOfKeyPoint保存到XML并再次加载,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13837608/

10-12 12:37