Exam Preparation Quiz

Question 8 of 75

Complete Face API Code For Adding Person Images

MDFT Pro, a well-known training agency, is developing a student recognition system using the Azure Face API to automatically identify students in training session photos. Claire, the Lead Developer, needs to create person groups for each course and add multiple photos of each student to improve recognition accuracy.

The application processes student profile images stored in organized directories, with each student having a folder containing multiple JPG photos. The code uses parallel processing to efficiently add all student images to their respective person groups in the Face API.

Here is the code that needs to be completed:

Parallel.For (0, PersonCount, async i =>
{
    Guid personId = persons[i].PersonId;
    string personImageDir = $"/path/to/person/{i}/images";
    foreach (string imagePath in Directory.GetFiles(personImageDir, "*.jpg"))
    {
        using (__________ t = File.OpenRead(imagePath))
        {
            // code to add face to person group goes here
        }
    }
});

What type should be used in the first placeholder to properly handle the image file stream?

Choose the correct answer from the options below.

Explanations for each answer:

Learn more about Face API person groups:
Face API Person Groups
Next Question