Submitted by: Srinath M S(srinath_ms@yahoo.com)

Wednesday Oct 9th 2019 by Srinath M S
Article Image

Language: .NET, Expertise: Intermediate - Learn how to detect and extract faces with Amazon Rekognition.

AmazonRekognitionClient amazonRekognitionClient = new AmazonRekognitionClient(Amazon.RegionEndpoint.<YourRegionName>);

byte[] imageData = System.IO.File.ReadAllBytes(inputImageFile);

DetectFacesRequest facesRequest = new DetectFacesRequest();

facesRequest.Image = new Amazon.Rekognition.Model.Image
Bytes = new MemoryStream(imageData)

DetectFacesResponse facesResponse = amazonRekognitionClient.DetectFaces(facesRequest);

//If faces are detected, extract them
if (facesResponse.FaceDetails.Count > 0)
foreach (var face in facesResponse.FaceDetails)
//save them to bitmap by cropping with bounds of the face object
Mobile Site | Full Site