Facial Expression [F200]

Top  Previous  Next

Configuring Facial Expression Detection

To configure facial expression detection, use the ExpressionsConfiguration interface, as shown in Example 48. The ExpressionsConfiguration interface enables/disables the detection algorithm as well as configuring individual expression.

C++ Example 48: Configure Facial Expression Detection

// cfg is a PXCFaceConfiguration instance

PXCFaceConfiguration::ExpressionsConfiguration *ecfg=cfg->QueryExpressions();

ecfg->Enable();

ecfg->EnableAllExpressions();

C# Example 48: Configure Facial Expression Detection

// cfg is a PXCMFaceConfiguration instance

PXCMFaceConfiguration.ExpressionsConfiguration ecfg=cfg.QueryExpressions();

ecfg.Enable();

ecfg.EnableAllExpressions();

Java Example 48: Configure Facial Expression Detection

// cfg is a PXCMFaceConfiguration instance

PXCMFaceConfiguration.ExpressionsConfiguration ecfg=cfg.QueryExpressions();

ecfg.Enable();

ecfg.EnableAllExpressions();

Expression Data

If you enable facial expression detection, you can use the QueryExpressions function to retrieve any detected expression data, described in the ExpressionsData interface. The algorithm supports the following groups of expressions (see the FaceExpression enumerator for definitions.)

Head Movement: For example, the head is turning left, or tilted right.
Eyebrow Movement: For example, the left/right eyebrow is raised or lowered.
Eye Movement: For example, the eyes are turning left or right.
Mouth Movement: For example, the mouth is open, or making a kiss action.

Each expression has an associated intensity parameter, which is part of the FaceExpressionResult structure, to indicate the likelihood/scale of the detection.

Example 49 illustrates the steps to retrieve the expression data.

C++ Example 49: Retrieve the Expression Data

// fdata is a PXCFaceData instance

pxcI32 nfaces=fdata->QueryNumberOfDetectedFaces();

for (pxcI32 i=0;i<nfaces;i++) {

   // Retrieve the data instance

   PXCFaceData::Face *face=fdata->QueryFaceByIndex(i);

   PXCFaceData::ExpressionsData *edata=fdata->QueryExpressions();

 

   // retrieve the expression information

   PXCFaceData::ExpressionsData::FaceExpressionResult score;

   edata->QueryExpression(PXCFaceData::ExpressionsData::EXPRESSION_SMILE, &score);

 

   // action based on detected expression

   ...

}

C# Example 49: Retrieve the Expression Data

// fdata is a PXCMFaceData instance

Int32 nfaces=fdata.QueryNumberOfDetectedFaces();

for (Int32 i=0;i<nfaces;i++) {

   // Retrieve the data instance

   PXCMFaceData.Face face=fdata.QueryFaceByIndex(i);

   PXCMFaceData.ExpressionsData edata=fdata.QueryExpressions();

 

   // retrieve the expression information

   PXCMFaceData.ExpressionsData.FaceExpressionResult score;

   edata.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_SMILE, out score);

 

   // action based on detected expression

   ...

}

Java Example 49: Retrieve the Expression Data

// fdata is a PXCMFaceData instance

int nfaces=fdata.QueryNumberOfDetectedFaces();

for (int i=0;i<nfaces;i++) {

   // Retrieve the data instance

   PXCMFaceData.Face face=fdata.QueryFaceByIndex(i);

   PXCMFaceData.ExpressionsData edata=fdata.QueryExpressions();

 

   // retrieve the expression information

   PXCMFaceData.ExpressionsData.FaceExpressionResult score=new PXCMFaceData.ExpressionsData.FaceExpressionResult();

   edata.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_SMILE, score);

 

   // action based on detected expression

   ...

}