private float[,] calcDist(EnumIndexableCollection <FeaturePoint, Vector3DF> fp) { int fpSize = fp.Count(); Vector3DF[] temp = new Vector3DF[fpSize]; float[,] fpRes = new float[fpSize, fpSize]; int k = 0; foreach (Vector3DF p in fp) { temp[k] = p; k++; } for (int i = 0; i < (fpSize - 1); i++) { for (int j = 0; j < (fpSize - 1); j++) { if (i == j) { } // Do stuff to temp! else { fpRes[i, j] = Math.Abs((float)Math.Sqrt((float)Math.Pow(temp[i].X - temp[j].X, 2) + (float)Math.Pow(temp[i].Y - temp[j].Y, 2) + (float)Math.Pow(temp[i].Z - temp[j].Z, 2))); } } } return(fpRes); }
private int pointsCount(EnumIndexableCollection <FeaturePoint, Vector3DF> fp) { int size = fp.Count(); return(size); }
/// <summary> /// Prepares the 3d face points and calls the ERTreesClassifier.Predict method /// </summary> /// <param name="forest">ERTreesClassifier object</param> /// <param name="face3DPoints">3d points of the face</param> /// <returns>ID of the face</returns> static public int Recognize(this ERTreesClassifier forest, EnumIndexableCollection<FeaturePoint, Vector3DF> face3DPoints) { var varCount = face3DPoints.Count; // x, y, z Matrix<float> data; data = new Matrix<float>(1, face3DPoints.Count()*3); for (int j = 0; j < varCount; j++) { data[0, j * 3] = face3DPoints[j].X; data[0, j * 3 + 1] = face3DPoints[j].Y; data[0, j * 3 + 2] = face3DPoints[j].Z; } var r = forest.Predict(data); return (int)r; }