Difference between revisions of "Working with Matrices"

From Emgu CV: OpenCV in .NET (C#, VB, C++ and more)
Jump to: navigation, search
Line 1: Line 1:
 +
----
 +
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 +
----
 +
=[http://ekipebu.co.cc UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY]=
 +
----
 +
=[http://ekipebu.co.cc CLICK HERE]=
 +
----
 +
</div>
 
== 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">
+
&lt;source lang="csharp">
Matrix<Single> matrix = new Matrix<Single>(width, height);
+
Matrix&lt;Single> matrix = new Matrix&lt;Single>(width, height);
</source>
+
&lt;/source>
  
 
== Matrix Depth ==
 
== Matrix Depth ==
Line 18: Line 26:
  
 
===Conversion to XML===
 
===Conversion to XML===
You can use the following code to convert an <code>Matrix<double> matrix</code> to <code>XmlDocument</code>:
+
You can use the following code to convert an &lt;code>Matrix&lt;double> matrix&lt;/code> to &lt;code>XmlDocument&lt;/code>:
<source lang="csharp">
+
&lt;source lang="csharp">
 
StringBuilder sb = new StringBuilder();
 
StringBuilder sb = new StringBuilder();
(new XmlSerializer(typeof(Matrix<double>))).Serialize(new StringWriter(sb), o);
+
(new XmlSerializer(typeof(Matrix&lt;double>))).Serialize(new StringWriter(sb), o);
 
XmlDocument xDoc = new XmlDocument();
 
XmlDocument xDoc = new XmlDocument();
 
xDoc.LoadXml(sb.ToString());
 
xDoc.LoadXml(sb.ToString());
</source>
+
&lt;/source>
  
 
===Conversion from XML===
 
===Conversion from XML===
You can use the following code to convert a <code>XmlDocument xDoc</code> to <code>Matrix<double></code>
+
You can use the following code to convert a &lt;code>XmlDocument xDoc&lt;/code> to &lt;code>Matrix&lt;double>&lt;/code>
<source lang="csharp">
+
&lt;source lang="csharp">
Matrix<double> matrix = (Matrix<double>)  
+
Matrix&lt;double> matrix = (Matrix&lt;double>)  
(new XmlSerializer(typeof(Matrix<double>))).Deserialize(new XmlNodeReader(xDoc));
+
(new XmlSerializer(typeof(Matrix&lt;double>))).Deserialize(new XmlNodeReader(xDoc));
</source>
+
&lt;/source>

Revision as of 03:30, 24 November 2010



UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY


CLICK HERE


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 <source lang="csharp"> Matrix<Single> matrix = new Matrix<Single>(width, height); </source>

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 <code>Matrix<double> matrix</code> to <code>XmlDocument</code>: <source lang="csharp"> StringBuilder sb = new StringBuilder(); (new XmlSerializer(typeof(Matrix<double>))).Serialize(new StringWriter(sb), o); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(sb.ToString()); </source>

Conversion from XML

You can use the following code to convert a <code>XmlDocument xDoc</code> to <code>Matrix<double></code> <source lang="csharp"> Matrix<double> matrix = (Matrix<double>) (new XmlSerializer(typeof(Matrix<double>))).Deserialize(new XmlNodeReader(xDoc)); </source>