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 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
    "Image"subimages containing each face
    "Position"the position of each face given as {x,y}
    "Strength"strength of the detected face
    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:
  • AcceptanceThresholdAutomaticdetection acceptance threshold
    MaxFeaturesAllnumber of faces to return
    MaxOverlapFractionAutomaticmaximum allowed overlap fraction
    MethodAutomaticmethod to use
    PerformanceGoal$PerformanceGoalwhat to optimize in the detection
    SortedByAutomaticfunction to use for sorting the result
  • 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
  • For multichannel images, FindFaces operates on grayscale intensities.
  • FindFaces uses machine learning, and its training set and methods may change in different versions of the Wolfram Language, yielding different results.

Examples

open all close all

Basic Examples  (2)

Find coordinates of faces in an image:

In[1]:=
Click for copyable input
Out[2]=

Extract subimages that include faces:

In[3]:=
Click for copyable input
Out[3]=

Detect and highlight a face in an image:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Scope  (7)

Options  (2)

Applications  (2)

Properties & Relations  (2)

Possible Issues  (3)

Introduced in 2012
(9.0)
|
Updated in 2019
(12.0)