Working with Matrices: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
== Depth as Generic Parameter == | == Depth as Generic Parameter == | ||
A Matrix is defined by its generic parameters '''depth'''. To create a 32bit floating point matrix, in [[Emgu CV]] it is done by calling | A Matrix is defined by its generic parameters '''depth'''. To create a 32bit floating point matrix, in [[Emgu CV]] it is done by calling | ||
<source lang="csharp"> | |||
Matrix | Matrix<Single> matrix = new Matrix<Single>(width, height); | ||
</source> | |||
== Matrix Depth == | == Matrix Depth == | ||
Line 26: | Line 18: | ||
===Conversion to XML=== | ===Conversion to XML=== | ||
You can use the following code to convert an | You can use the following code to convert an <code>Matrix<double> matrix</code> to <code>XmlDocument</code>: | ||
<source lang="csharp"> | |||
StringBuilder sb = new StringBuilder(); | StringBuilder sb = new StringBuilder(); | ||
(new XmlSerializer(typeof(Matrix | (new XmlSerializer(typeof(Matrix<double>))).Serialize(new StringWriter(sb), o); | ||
XmlDocument xDoc = new XmlDocument(); | XmlDocument xDoc = new XmlDocument(); | ||
xDoc.LoadXml(sb.ToString()); | xDoc.LoadXml(sb.ToString()); | ||
</source> | |||
===Conversion from XML=== | ===Conversion from XML=== | ||
You can use the following code to convert a | You can use the following code to convert a <code>XmlDocument xDoc</code> to <code>Matrix<double></code> | ||
<source lang="csharp"> | |||
Matrix | Matrix<double> matrix = (Matrix<double>) | ||
(new XmlSerializer(typeof(Matrix | (new XmlSerializer(typeof(Matrix<double>))).Deserialize(new XmlNodeReader(xDoc)); | ||
</source> |
Latest revision as of 09:53, 26 November 2010
Depth as Generic Parameter
A Matrix is defined by its generic parameters depth. To create a 32bit floating point matrix, in Emgu CV it is done by calling
Matrix<Single> matrix = new Matrix<Single>(width, height);
Matrix Depth
The types of depth supported in Emgu CV 1.4.0.0 include
- Byte
- SByte
- Single (float)
- Double
- UInt16
- Int16
- Int32 (int)
XML Serialization
Conversion to XML
You can use the following code to convert an Matrix<double> matrix
to XmlDocument
:
StringBuilder sb = new StringBuilder();
(new XmlSerializer(typeof(Matrix<double>))).Serialize(new StringWriter(sb), o);
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(sb.ToString());
Conversion from XML
You can use the following code to convert a XmlDocument xDoc
to Matrix<double>
Matrix<double> matrix = (Matrix<double>)
(new XmlSerializer(typeof(Matrix<double>))).Deserialize(new XmlNodeReader(xDoc));