I’m currently trying to track a users face using xbox kinect. I have taken some of the code from “Face tracking basics” and to store the location of the points it uses:
var faceModelPts = new List<Point>();
var faceModel = new List<FaceModelTriangle>();
for (int i = 0; i < this.facePoints.Count; i++)
{
faceModelPts.Add(new Point(this.facePoints[i].X + 0.5f, this.facePoints[i].Y + 0.5f));
}
I want to be able to use the information to calculate the distance between some of these points. So I have tried putting them in a separate array like this:
var faceModelPts = new List<Point>();
var faceModel = new List<FaceModelTriangle>();
double[] xarray;
double[] yarray;
for (int i = 0; i < this.facePoints.Count; i++)
{
faceModelPts.Add(new Point(this.facePoints[i].X + 0.5f, this.facePoints[i].Y + 0.5f));
xarray[i] = this.facePoints[i].X;
yarray[i] = this.facePoints[i].Y;
}
but this seems to return errors. But I can get the information by doing the following:
double xpos21 = this.facePoints[21].X;
Is there just a simple error in what i’m doing or can this information not be placed into an array this way?
Also once I have the positions of the points how do I go about retrieving the depth information at this location?
You do not appear to be initializing your arrays.
That would explain the null pointer in your array, unless you’re declaring this outside your quoted code.
Set a breakpoint on that line in Visual Studio. When you hit it during a Debug, check to verify that
xarrayis not null.