Last active
June 10, 2019 00:55
-
-
Save fernandoseguim/1ad9164484e58b34e2a3d55fdc63df85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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