Open topic with navigation

# Automatically Enroll Unrecognized Faces

Media Server can automatically enroll unrecognized faces (add them to the training database).

A configuration to enroll unrecognized faces is included with Media Server (`faceenroll.cfg`, in the `configurations` folder). It contains the following steps:

- Face detection, to detect all faces that appear in the media.
- An event stream processing (ESP) task, to discard faces that are in profile or partially outside the image. To achieve the best performance, face recognition should be trained with images that show a complete face with both eyes visible.
- Face recognition, to determine whether a face is already present in the training database. This task uses the `RecognitionThreshold` parameter to specify the minimum confidence required to successfully recognize a face.
- An event stream processing (ESP) task, to discard faces that were successfully recognized in the previous step, because these faces do not need to be added to the database. This task runs a Lua script to discard records that have an `identity` element in their metadata.
- A crop transformation task, to create cropped images that each show a single unrecognized face. Images that contain more than one face cannot be used for training face recognition, so this step is important in case several unrecognized people appear at the same time.
- An enroll analysis task, to enroll the cropped images of unrecognized faces in the database.
- An output task so that you can see what Media Server has added to the database. To see the images, you could also add an encoding task, or use the action `GetFaceImage` after enrollment is complete.

The following procedure describes how to configure an enroll task, and the example configuration that includes all of these tasks is included below.

To automatically enroll faces

1. Open the configuration that you want to modify.

2. In the `[Analysis]` section, add a new task by setting the `AnalysisEngineN` parameter.

3. Create a new configuration section that matches the name of the task and configure Media Server to enroll the images. Use the following configuration parameters:

   `Type` | The engine to use. Set this parameter to `Enroll`.
   `Module` | Set this parameter to `Face`.
   `Input` | The track that contains the images to enroll.
   `Database` | The name of the database to add the faces to. HPE recommends that you add faces to a new database, not the database you use for recognition. An operator can then check the enrolled faces. For example, you should make sure that all of the images added to a face represent the same person. After verifying the enrolled faces, you can move them to the correct recognition database.
   `PostAction` | Specifies what Media Server should do after enrolling an image in the database. The default value, `build`, trains Media Server to recognize the face.
   `PostSyncDatabase` | Specifies whether Media Server should synchronize with the training database after enrolling an image. You might want to use this parameter if you are adding faces to the same database that is used for recognition. If an unrecognized face appears again but you have not trained Media Server and synchronized with the database, the face remains unrecognized. This means that Media Server adds another entry to the database for the same face. If you are enrolling faces in a different database to the one that is used for recognition, there is no need to set this parameter.
   `Identifier` | The identifier to use when adding a new face to the database. HPE recommends using the macro `%record.id%`, because this identifier is set by the face detection task and is unique for each detected face.

   For example:

       [EnrollFaces]
       Type=Enroll
       Module=Face
       Input=CropFaces.Output
       Database=EnrolledFaces
       PostAction=Build
       PostSyncDatabase=TRUE
       Identifier=%record.id%

4. Save and close the configuration file. HPE recommends that you save your configuration files in the location specified by the `ConfigDirectory` parameter.

Example configuration to enroll unrecognized faces

    [Ingest]
    IngestEngine=AV

    [AV]
    Type=libav

    [Analysis]
    AnalysisEngine0=FaceDetect
    AnalysisEngine1=FaceRecognize
    AnalysisEngine2=EnrollFace

    [FaceDetect]
    Type=FaceDetect
    NumParallel=6

    [FaceRecognize]
    Type=FaceRecognize
    Input=FaceFilter.Output
    Database=People
    NumParallel=2
    MaxRecognitionResults=1
    // Faces that do not meet the recognition threshold are considered
    // to be unknown and are enrolled in the database.
    RecognitionThreshold=65

    [EnrollFace]
    Type=Enroll
    Module=Face
    Input=CropToFace.Output
    Database=EnrolledFaces
    Identifier=%record.id%

    [EventProcessing]
    EventProcessingEngine0=FaceFilter
    EventProcessingEngine1=UnknownFaces

    [FaceFilter]
    // Filter out profile faces, and those partially outside image
    Type=Filter
    Input=FaceDetect.ResultWithSource
    LuaScript=configurations/frontalface.lua

    [UnknownFaces]
    // Discard recognized faces (those that have an identifier set).
    Type=Filter
    Input=FaceRecognize.ResultWithSource
    LuaScript=configurations/unknownface.lua

    [Transform]
    TransformEngine=CropToFace

    [CropToFace]
    Type=Crop
    Input=UnknownFaces.Output
    Border=50

    [Output]
    OutputEngine=XML

    [XML]
    // Record new identities, and any training errors
    Type=XML
    Mode=SingleRecord
    Input=EnrollFace.Result
    XMLOutputPath=output/%session.token%/enrollment_%record.id%.xml

The script `frontalface.lua` contains the following function, to discard faces that appear in profile or are partially outside the image:

    function pred(x)
      return x.FaceResultAndImage.face.outofplaneanglex ~= 90
        and x.FaceResultAndImage.face.outofplaneanglex ~= -90
        and x.FaceResultAndImage.face.percentageinimage > 95
    end

The script `unknownface.lua` contains the following function, to discard faces that were successfully recognized:

    function pred(x)
       return x.FaceRecognitionResultAndImage.identity.identifier == nil
    end

© 2017 Hewlett Packard Enterprise Development LP | Send documentation feedback to HPE Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to AutonomyTPFeedback@hpe.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_HP_HTML5_bannerTitle.htm