Skip to content

Instantly share code, notes, and snippets.

@fernandoseguim
Last active June 10, 2019 00:55
Show Gist options
  • Save fernandoseguim/1ad9164484e58b34e2a3d55fdc63df85 to your computer and use it in GitHub Desktop.
Save fernandoseguim/1ad9164484e58b34e2a3d55fdc63df85 to your computer and use it in GitHub Desktop.
var image1 = await File.ReadAllBytesAsync("path\\to\\source\\image");
var image2 = await File.ReadAllBytesAsync("path\\to\\target\\image");
const float SIMILARITY_THRESHOLD = 75;
const float CONFIDENCE_LEVEL = 95;
using(var source = new MemoryStream(image1))
using(var target = new MemoryStream(image2))
{
var request = new CompareFacesRequest
{
SourceImage = new Image { Bytes = source },
TargetImage = new Image { Bytes = target },
SimilarityThreshold = SIMILARITY_THRESHOLD
};
var reponse = await amazonRekognitionClient.CompareFacesAsync(request);
Console.WriteLine(HaveSamePerson(reponse.FaceMatches, similarity:SIMILARITY_THRESHOLD, confidence: CONFIDENCE_LEVEL)
? "The person in the source image is in the target image"
: "The person in the source image isn't in the target image");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment