FindFaces

FindFaces[image]

attempts to find human faces in image and returns a list of bounding boxes.

FindFaces[image,prop]

returns the specified property prop for each detected face.

FindFaces[image,crit,prop]

finds faces that satisfy the criterion crit.

Details and Options

  • FindFaces is also known as face detection.
  • Face detection is a common computer vision technique that returns detected faces as a list of bounding boxes, each given as a Rectangle object.
  • Coordinates {x,y} are assumed to be in the standard image coordinate system.
  • The property prop can be any of the following:
  • "BoundingBox"bounding boxes returned as Rectangle objects
    "BoundingBoxArea"pixel area of each face
    "Confidence"strength of the detected face
    "Image"subimages containing each face
    "Position"the position of each face given as {x,y}
    featureany feature available in FacialFeatures
    {prop1,prop2,}a list of properties
  • The criterion crit can be any of the following:
  • {min,max}faces of size min through max in pixels
    {Scaled[amin],Scaled[amax]}faces of relative size amin to amax
    ffaces that satisfy f
  • When a pure function f is used, facial features such as age and gender can be accessed using #Age and #Gender. A face is returned if f returns True.
  • For the complete list of facial features, see the reference page for FacialFeatures.
  • The following options can be given:
  • AcceptanceThreshold Automaticdetection acceptance threshold
    MaxFeatures Allnumber of faces to return
    MaxOverlapFraction Automaticmaximum allowed overlap fraction
    Method Automaticmethod to use
    Padding "Fixed"padding scheme to use at image boundaries
    PaddingSize 0amount of padding around each detected face
    PerformanceGoal $PerformanceGoalwhat to optimize in the detection
    SortedBy Automaticfunction to use for sorting the result
  • With PaddingSize->x, each detected face is padded by x pixels on each side. Using PaddingSize->Scaled[s], each face is padded by a fraction s of its bounding box.
  • If available, faces are padded with image content. At the boundaries, the setting of Padding is used.
  • By default, detected faces are sorted based on their strength. Use SortedBy->f to specify a different sorting function. The function f can access available properties using the pattern #prop.
  • Possible settings for Method include:
  • "Haar"cascade detector based on Haar features
    "LocalBinaryPatterns"cascade detector based on LBP features
    "SingleShotDetector"neural network detector based on SSD architecture
    {method1,method2,}aggregates the result of all methodi
  • For multichannel images, the "Haar" and "LocalBinaryPatterns" methods operate on grayscale intensities.
  • FindFaces uses machine learning. Its methods, training sets and biases included therein may change and yield varied results in different versions of the Wolfram Language.
  • FindFaces may download resources that will be stored in your local object store at $LocalBase, and that can be listed using LocalObjects[] and removed using ResourceRemove.

Examples

open allclose all

Basic Examples  (2)

Find coordinates of faces in an image:

Extract subimages that include faces:

Detect and highlight a face in an image:

Scope  (7)

Properties  (4)

Compute the face bounding box:

Extract the portion of the image corresponding to the bounding box:

Extract multiple properties:

Extract features available in FacialFeatures:

Criteria  (3)

Use a computable property as a test argument:

Some test results can be used as shortcuts for the whole test:

Find faces of all sizes:

Specify a maximum face size in pixels:

Specify a minimum face size in pixels:

Use Scaled to specify the face size relative to the image dimensions:

Options  (10)

AcceptanceThreshold  (1)

By default, all the detected faces are returned:

Use AcceptanceThresholdt to return only detections with strength greater than t:

Use AcceptanceThreshold0 to return all the detected faces:

MaxFeatures  (1)

By default, all the detected faces are returned:

Use MaxFeaturesn to return only the n strongest detections:

MaxOverlapFraction  (1)

By default, all the detected faces are returned, regardless of their overlapping:

Find only non-overlapping faces:

Allow up to 2 percent of overlap:

Method  (2)

FindFaces automatically picks the detection method:

Specify the method to use:

Use the combined result from multiple methods:

The "LocalBinaryPatterns" method is a cascade classifier that works on a histogram of the gradients (HoG) features. It is a very fast and lightweight multiscale method:

The "Haar" method is a cascade classifier working on Haar features. It is more robust than "LocalBinaryPatterns" but generally slower:

The "SingleShotDetector" method is based on a single neural net evaluation, and it is very stable with respect to variations in pose, illumination, occlusion and subjects. It is slower compared to two other methods:

Padding  (1)

The bounding box of a detection can be padded beyond the image boundary:

Specify a custom padding specification:

PaddingSize  (2)

FindFaces by default returns a fairly tight crop around each face:

Specify a padding size to be added around each face:

Specify a negative padding to crop more:

Specify a scaled padding:

Compare detected faces using different paddings:

PerformanceGoal  (1)

Use PerformanceGoal"Quality" to emphasize the quality of the result:

Use PerformanceGoal"Speed" to emphasize the speed of computation:

SortedBy  (1)

By default, detections are sorted by "Confidence":

Specify a different property:

Applications  (3)

Find and highlight detected faces:

Find and blur all detected faces:

Dynamic detection of faces:

Find the number of faces in each video frame:

Plot the result:

Properties & Relations  (2)

Faces may be detected in spite of rotation in the image plane:

Faces may be detected in spite of intensity changes:

Possible Issues  (3)

Upright faces are usually better detected:

Other faces may be detected when rotating the image:

Faces turned away from the camera may not be detected:

Very small or low resolution faces may not be detected:

Resampling the image may improve the detection:

Wolfram Research (2012), FindFaces, Wolfram Language function, https://reference.wolfram.com/language/ref/FindFaces.html (updated 2024).

Text

Wolfram Research (2012), FindFaces, Wolfram Language function, https://reference.wolfram.com/language/ref/FindFaces.html (updated 2024).

CMS

Wolfram Language. 2012. "FindFaces." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/FindFaces.html.

APA

Wolfram Language. (2012). FindFaces. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FindFaces.html

BibTeX

@misc{reference.wolfram_2024_findfaces, author="Wolfram Research", title="{FindFaces}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/FindFaces.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_findfaces, organization={Wolfram Research}, title={FindFaces}, year={2024}, url={https://reference.wolfram.com/language/ref/FindFaces.html}, note=[Accessed: 22-December-2024 ]}