FlashFoto Logo

Overview

Resources

Download

Concepts & Tricks

Handling Multiple Faces in a Photo

Often times the photos that people upload or have online include more than one person.
The default behavior of the background removal technology differs depending on the API call:
Face & Hair

- faces are prioritized by dominance or by a confidence score;

- the highest score is the face that is processed

Mugshot

- the latest version of mugshot will handle multiple people and return them together in one mask;

- this provides the option to do buddy-shots so two or more people can be removed from the background as one unit or mask


When using Face & Hair you may want to get all of the heads in a photo or pick particular
heads in the photo. You can accomplish this in a couple of ways:
Select a face

- Use the Find Face Method to get all of the face coordinates

- Pass the face selections to the UI and wait for user selection, or utilize another
external data source such as a Facebook image tag with coordinates

- Use the Copy Method to crop a selection around the face

- Pass this cropped selection to the Segment Method

Process all faces

- Use the Find Face Method to get all of the face coordinates

- Use the Copy Method to crop a selection around each of the faces

- Pass each of the cropped selections to the Segment Method

Filtering Out Poor Results or Candidate Faces

Many photos found online are poor candidates for automated background removal. It is possible to use the scoring returned from the Find Faces Method to exclude lower scoring faces. Depending on your use cases you may want to only include faces scoring over 90. Lower scoring faces are more likely to have less than ideal results in removing the background.

Editing Results of Uniform Background Removal

There are some cases you may want to offer users an editing tool so that users can quickly touch up the results from the automated background removal.

When using any of the background removal APIs on images of low quality, poor contrast or lighting, the algorithm may not handle certain portions according to the desired result. Other conditions such as overlapping faces in group shots and occlusion of the face due to positioning of the head or otherwise as well as lengthy or busy beards can lead to undesirable results.

To accomplish editing you need to provide a user interface that can select certain pixels to add or remove. Then all you need to do is:

- Call the Copy Method of the API to grab the HardMasked version of the image

- Use the dest_id and dest_version to create an edited version by passing in the pixels of the newly edited mask

- You may also want to update the SoftMasked version according to the edits if you plan to offer any neck blending features.