private float[] ExtractInputFeatures(Dictionary <string, Vector3> points) { points = new Dictionary <string, Vector3>(points); // Defensive copy var alignmentPoints = new Dictionary <string, Vector3>(); foreach (var id in handTemplate.AlignmentMarkerList) { alignmentPoints.Add(id, points[id]); Debug.Assert(!float.IsNaN(points[id].x), "Alignment marker is NaN"); } double[,] R; double[] offset; handTemplate.AlignTransform(alignmentPoints, points, out R, out offset); var markerList = handTemplate.MarkerList; float[] features = new float[markerList.Count * 3]; for (int i = 0; i < markerList.Count; i++) { Vector3 pos = points[markerList[i]]; features[3 * i + 0] = pos.x; features[3 * i + 1] = pos.y; features[3 * i + 2] = pos.z; if (float.IsNaN(pos.x)) { Debug.Assert(!float.IsNaN(pos.x), "NaNs detected in the neural network input (might happen during warmup)"); features[3 * i + 0] = features[3 * i + 1] = features[3 * i + 2] = 0; } } return(features); }
private float[] ExtractInputFeatures(Dictionary <string, Vector3> points, out double[,] R, out double[] offset) { points = new Dictionary <string, Vector3>(points); // Defensive copy handTemplate.AlignTransform(points, points, out R, out offset); var pointList = new List <Vector3>(handTemplate.MarkerList.Count); foreach (var marker in handTemplate.MarkerList) { if (points.ContainsKey(marker)) { pointList.Add(points[marker]); } else { // Missing values are set to 0 pointList.Add(Vector3.zero); } } // Flatten input vectors float[] features = new float[pointList.Count * 3]; for (int i = 0; i < pointList.Count; i++) { features[3 * i + 0] = pointList[i].x; features[3 * i + 1] = pointList[i].y; features[3 * i + 2] = pointList[i].z; } return(features); }