如果使用EnumIndexableCollection<FeaturePoint, PointF>
所以你可以使用一個FaceTrackFrame
的GetProjected3DShape()
方法。 你使用這樣的:
private byte[] colorImage;
private ColorImageFormat colorImageFormat = ColorImageFormat.Undefined;
private short[] depthImage;
private DepthImageFormat depthImageFormat = DepthImageFormat.Undefined;
KinectSensor Kinect = KinectSensor.KinectSensors[0];
private Skeleton[] skeletonData;
colorImageFrame = allFramesReadyEventArgs.OpenColorImageFrame();
depthImageFrame = allFramesReadyEventArgs.OpenDepthImageFrame();
skeletonFrame = allFramesReadyEventArgs.OpenSkeletonFrame();
colorImageFrame.CopyPixelDataTo(this.colorImage);
depthImageFrame.CopyPixelDataTo(this.depthImage);
skeletonFrame.CopySkeletonDataTo(this.skeletonData);
skeletonData = new Skeleton[skeletonFrame.SkeletonArrayLength];
foreach(Skeleton skeletonOfInterest in skeletonData)
{
FaceTrackFrame frame = faceTracker.Track(
colorImageFormat, colorImage, depthImageFormat, depthImage, skeletonOfInterest);
}
private EnumIndexableCollection<FeaturePoint, PointF> facePoints = frame.GetProjected3DShape();
然後你就可以在你的形象使用每個點。 我想有一個const double preferedDistance
,你可以乘以不同點的當前 深度x和y找到 x和y的首選版本和深度由下式
preferredDistance/currentDistance
例子:
const double preferredDistance = 500.0;//this can be any number you want.
double currentDistance = //however you are calculating the distance
double whatToMultiply = preferredDistance/currentDistance;
double x1 = this.facePoints[39].X;
double y1 = this.facePoints[39].Y;
double x2 = this.facePoints[8].X;
double y2 = this.facePoints[8].Y;
double result = whatToMultiply * //however you are calculating distance.
然後你就可以擁有的距離是搜索什麼List<>
。 我還建議你有一個List<>
布爾值,它與 距離一致,如果結果匹配,則設置爲true,所以你可以跟蹤哪個 bool是真/假。
實施例:
List<double> DistanceFromEyeToNose = new List<double>
{
1,
2,
3 //etc
};
List<bool> IsMatch = new List<bool>
{
false,
false,
false //etc
};
然後通過使用for
循環搜索。
for (int i = 0; i < DistanceFromEyeToNose.Count; i++)
{
if (result == DistanceFromEyeToNose[i]) IsMatch[i] = true;
}
希望能幫到你!
請添加一些代碼/甚至你正在使用的代數和距離的圖表 –