I find a sample code that uses Azure Face API ->https://github.com/jernejk/RealTimeFaceApi
I found DetectFace time + Recognize Facetime is too long so I tried to optimize by cropping the image to only the face (with 10-30% padding) to have <80kB upload. Although the time has become shorter, it is not "real-time". Please refer to the below Log:
This is the code segment↓
private static async Task StartRecognizing(Mat image)
{
try
{
// TODO: Optimize by cropping the image to only the face (with 10-30% padding) to have <50kB upload.
var stream = image.ToMemoryStream();
Console.WriteLine(DateTime.Now + ": Sending " + (stream.Length / 1024) + "kB to recognize face.");
Stopwatch stopwatch = Stopwatch.StartNew();
detectedFaces = await _faceClient.Face.DetectWithStreamAsync(stream, true, false);
var faceIds = detectedFaces.Where(f => f.FaceId.HasValue).Select(f => f.FaceId.Value).ToList();
Console.WriteLine(DateTime.Now + ": Found " + faceIds.Count + " faces in " + stopwatch.ElapsedMilliseconds + "ms.");
stopwatch.Stop();
if (faceIds.Any())
{
stopwatch.Restart();
var potentialUsers = await _faceClient.Face.IdentifyAsync(faceIds, FaceGroupId);
stopwatch.Stop();
Console.WriteLine(DateTime.Now + ": Recognized " + potentialUsers.Count + " candidates in " + stopwatch.ElapsedMilliseconds + "ms.");
foreach (var candidate in potentialUsers.Select(u => u.Candidates.FirstOrDefault()))
{
var candidateName = await GetCandidateName(candidate?.PersonId);
Console.WriteLine($"{DateTime.Now}: {candidateName} ({candidate?.PersonId})");
}
}
else
{
Console.WriteLine(DateTime.Now + $": No clear shot on the faces.");
}
}
catch (APIErrorException apiError)
{
Console.WriteLine(DateTime.Now + ": Cognitive service error: " + apiError?.Body?.Error?.Message);
}
catch (Exception e)
{
Console.WriteLine(DateTime.Now + ": Getting identity failed: " + e.ToString());
}
_faceRecognitionTask = null;
}
What I want to know is
Does the speed of FaceAPI completely depend on network speed?