public async Task<NamedFace[]> AnalyzeImageUsingHelper(Stream stream) { Face[] faces = await faceDetector.DetectAsync(stream, false, true, true, false); NamedFace[] namedFaces = new NamedFace[faces.Length]; //Copy to named faces vector. for (int i = 0; i < faces.Length; i++) { namedFaces[i] = new NamedFace(faces[i]); } // TODO: Is this the right place to get the images from??? bool identifyFaces; bool.TryParse(ConfigurationManager.AppSettings["IdentifySpecificPeople"] ?? "false", out identifyFaces); if (identifyFaces && faces.Length > 0) { var faceIds = faces.Select(face => face.FaceId).ToArray(); var results = await faceDetector.IdentityAsync("coworkers", faceIds); foreach (var identifyResult in results) { Console.WriteLine("Result of face: {0}", identifyResult.FaceId); if (identifyResult.Candidates.Length == 0) { Console.WriteLine("No one identified"); } else { var candidateId = identifyResult.Candidates[0].PersonId; var person = await faceDetector.GetPersonAsync("coworkers", candidateId); if (identifyResult.Candidates[0].Confidence > 0.5) { for (int i=0; i<namedFaces.Length; i++) { if (namedFaces[i].FaceId == identifyResult.FaceId) { // Set name. namedFaces[i].Name=person.Name; } } Console.WriteLine("Identified as {0}", person.Name); } } } } return namedFaces; }
public FaceMarker(NamedFace face) { this.HairlineColor = new SolidColorBrush(Colors.Red); InitializeComponent(); if (face.Name == "Scott") { Age = "40"; Gender = "male"; } else if (face.Name == "Kevin") { Age = "49"; Gender = "male"; } else { Age = face.Attributes.Age.ToString(); Gender = face.Attributes.Gender; } }