public static void Example() { String collectionId = "MyCollection"; String faceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient(); // Search collection for faces matching the face id. SearchFacesRequest searchFacesRequest = new SearchFacesRequest() { CollectionId = collectionId, FaceId = faceId, FaceMatchThreshold = 70F, MaxFaces = 2 }; SearchFacesResponse searchFacesResponse = rekognitionClient.SearchFaces(searchFacesRequest); Console.WriteLine("Face matching faceId " + faceId); Console.WriteLine("Matche(s): "); foreach (FaceMatch face in searchFacesResponse.FaceMatches) { Console.WriteLine("FaceId: " + face.Face.FaceId + ", Similarity: " + face.Similarity); } }
public List <FaceRecord> Recognize(string collectionId, Amazon.Rekognition.Model.Image image) { //1- Detect faces in the input image and adds them to the specified collection. AmazonRekognitionClient rekognitionClient = AmazonClient.GetInstance(); IndexFacesRequest indexFacesRequest = new IndexFacesRequest() { Image = image, CollectionId = collectionId, DetectionAttributes = new List <String>() { "DEFAULT" } }; IndexFacesResponse indexFacesResponse = rekognitionClient.IndexFaces(indexFacesRequest); //2- Search all detected faces in the collection SearchFacesResponse searchFacesResponse = null; List <FaceRecord> matchedFaces = new List <FaceRecord>(); if (null != indexFacesResponse && null != indexFacesResponse.FaceRecords && 0 != indexFacesResponse.FaceRecords.Count) { foreach (FaceRecord face in indexFacesResponse.FaceRecords) { searchFacesResponse = rekognitionClient.SearchFaces(new SearchFacesRequest { CollectionId = collectionId, FaceId = face.Face.FaceId, FaceMatchThreshold = 70F, MaxFaces = 2 }); if (searchFacesResponse.FaceMatches != null && searchFacesResponse.FaceMatches.Count != 0) { matchedFaces.Add(face); } } //Remove newly added faces to the collection _collectionService.RemoveFacesFromCollection(collectionId, indexFacesResponse.FaceRecords.Select(x => x.Face.FaceId).ToList()); } return(matchedFaces); }
public void RekognitionSearchFaces() { #region to-delete-a-face-1482182799377 var client = new AmazonRekognitionClient(); var response = client.SearchFaces(new SearchFacesRequest { CollectionId = "myphotos", FaceId = "70008e50-75e4-55d0-8e80-363fb73b3a14", FaceMatchThreshold = 90, MaxFaces = 10 }); List <FaceMatch> faceMatches = response.FaceMatches; string searchedFaceId = response.SearchedFaceId; #endregion }