title: Creating a 3D face mesh for Kinects depth field
body: <p>The Kinect SDK comes with an example of creating a face mesh on the colour stream. That looks like:</p>
  
  <p><a href="http://imgur.com/TV6dHBC" rel="nofollow">http://imgur.com/TV6dHBC</a></p>
  
  <p>I want to create a 3D mesh for the depth stream</p>
  
  <p>My code currently looks as follows:</p>
  
  <pre><code>private EnumIndexableCollection&lt;FeaturePoint, PointF&gt; facePoints;
  private EnumIndexableCollection&lt;FeaturePoint, Vector3DF&gt; depthPoints;
  
  public void DrawFaceModel(DrawingContext drawingContext)
  {
      if (!this.lastFaceTrackSucceeded || this.skeletonTrackingState != SkeletonTrackingState.Tracked)
          return;
  
      var faceModelPts = new List&lt;Point&gt;();
      var faceModelPts3D = new List&lt;Point3D&gt;();
      var faceModel = new List&lt;FaceModelTriangle&gt;();
      var faceModel3D = new List&lt;FaceModelTriangle3D&gt;();
  
      for (int i = 0; i &lt; this.facePoints.Count; i++)
      {
          faceModelPts3D.Add(new Point3D(this.depthPoints[i].X + 0.5f, this.depthPoints[i].Y + 0.5f, this.depthPoints[i].Z + 0.5f));
      }
  
      FaceDataPoints.Number_of_Points = this.facePoints.Count;
  
      foreach (var t in ImageData.faceTriangles)
      {
          var triangle = new FaceModelTriangle3D();
          triangle.Point1_3D = faceModelPts3D[t.First];
          triangle.Point2_3D = faceModelPts3D[t.Second];
          triangle.Point3_3D = faceModelPts3D[t.Third];
          faceModel3D.Add(triangle);
      }
  
      var faceModelGroup = new GeometryGroup();
      for (int i = 0; i &lt; faceModel.Count; i++)
      {
          var faceTriangle = new GeometryGroup();  
          faceTriangle.Children.Add(new LineGeometry(faceModel3D[i].Point1_3D, faceModel3D[i].Point2_3D)); 
          faceTriangle.Children.Add(new LineGeometry(faceModel3D[i].Point2_3D, faceModel3D[i].Point3_3D));
          faceTriangle.Children.Add(new LineGeometry(faceModel3D[i].Point3_3D, faceModel3D[i].Point1_3D));
          faceModelGroup.Children.Add(faceTriangle); //Add lines to image
      }
  
      drawingContext.DrawGeometry(Brushes.LightYellow, new Pen(Brushes.LightYellow, 1.0), faceModelGroup);
  }
  
  private struct FaceModelTriangle3D
  {
       public Point3D Point1_3D;
       public Point3D Point2_3D;
       public Point3D Point3_3D;
  }
  </code></pre>
  
  <p>I am currently getting the error 
  "Error  2   Argument 1: cannot convert from 'System.Windows.Media.Media3D.Point3D' to 'System.Windows.Point'    F:\Work\Uni\4th Year\Final Year Project\Project\Project 3.0\Project 3.0\FaceTrackingViewer.xaml.cs  275 68  Project 3.0
  "</p>
  
  <p>Which is being caused by:</p>
  
  <pre><code>(new LineGeometry(faceModel3D[i].Point2_3D, faceModel3D[i].Point3_3D));
  </code></pre>
  
  <p>What do I need to use instead of LineGeometry to get this working or is there a much more effective way of doing this?</p>
  
  <p>Also once I have created the face mesh I also want to be able to store this information to be able to calculate the distance between points on the face. So how would I go about storing the triangles information? </p>