Skip to content

Instantly share code, notes, and snippets.

@fernandoseguim
Created June 10, 2019 01:37
Show Gist options
  • Save fernandoseguim/54036b163f7d1552a9ef465476dbf578 to your computer and use it in GitHub Desktop.
Save fernandoseguim/54036b163f7d1552a9ef465476dbf578 to your computer and use it in GitHub Desktop.
const float CONFIDENCE_LEVEL = 90;
var count = 0;
using(var source = new MemoryStream(image))
{
var request = new DetectFacesRequest { Image = new Image() { Bytes = source }, Attributes = new List<string> { "ALL" } };
var response = await amazonRekognitionClient.DetectFacesAsync(request);
foreach(var faceDetail in response.FaceDetails)
{
Console.WriteLine($"Person {++count}");
Console.WriteLine(faceDetail.Gender.Confidence > CONFIDENCE_LEVEL
&& faceDetail.Gender.Value.Value.Equals("male", StringComparison.InvariantCultureIgnoreCase)
? "appears to be male"
: "appears to be female");
Console.WriteLine(faceDetail.Smile.Confidence > CONFIDENCE_LEVEL && faceDetail.Smile.Value is true ? "smiling" : "not smiling");
Console.WriteLine(faceDetail.Beard.Confidence > CONFIDENCE_LEVEL && faceDetail.Beard.Value is true ? "has a beard" : "does not have a beard");
Console.WriteLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment