Kinect SDK 附带了一个在颜色流上创建面部网格的示例。看起来像:
我想为深度流创建一个 3D 网格
我的代码目前如下所示:
private EnumIndexableCollection<FeaturePoint, PointF> facePoints;
private EnumIndexableCollection<FeaturePoint, Vector3DF> depthPoints;
public void DrawFaceModel(DrawingContext drawingContext)
{
if (!this.lastFaceTrackSucceeded || this.skeletonTrackingState != SkeletonTrackingState.Tracked)
return;
var faceModelPts = new List<Point>();
var faceModelPts3D = new List<Point3D>();
var faceModel = new List<FaceModelTriangle>();
var faceModel3D = new List<FaceModelTriangle3D>();
for (int i = 0; i < 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 < 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;
}
我目前收到错误“错误 2 参数 1:无法从 'System.Windows.Media.Media3D.Point3D' 转换为 'System.Windows.Point' F:\Work\Uni\4th Year\Final Year Project\Project\项目 3.0\项目 3.0\FaceTrackingViewer.xaml.cs 275 68 项目 3.0"
这是由以下原因引起的:
(new LineGeometry(faceModel3D[i].Point2_3D, faceModel3D[i].Point3_3D));
我需要使用什么来代替 LineGeometry 才能使其正常工作,或者是否有更有效的方法来做到这一点?
此外,一旦我创建了面部网格,我还希望能够存储这些信息,以便能够计算面部点之间的距离。那么我将如何存储三角形信息呢?