Add a Face to a Database (Using a Single Action)

You can train Media Server to recognize a face by sending a single action (TrainFace).

Running this action is equivalent to running the following actions in the following order:

  • NewFace
  • AddFaceImages
  • AddFaceMetadata (optional)
  • BuildFace

The TrainFace action is atomic, so that any interruption to the server does not leave the database in an inconsistent state.

Alternatively, you can train Media Server by sending these actions individually. You might want to do this if you are building a front end application that trains Media Server in response to user input. For more information about how to do this, see Add a Face to a Database (Using Separate Steps).

To add a face to a database (using a single action)

  • Add a face using the TrainFace action. For example:

    curl http://localhost:14000/action=TrainFace
                                -F database=Faces
                                -F imagedata=@face1_smile.jpg,face1_neutral.jpg
                                -F imagelabels=image1,image2
                                -F "metadata=lastname:Smith,fullname:\"John Smith, Jr\""

    Alternatively, the following example provides the paths of the training images rather than sending the image data:

    curl http://localhost:14000/action=TrainFace
                                -F database=Faces
                                -F imagepath=face1_smile.jpg,face1_neutral.jpg
                                -F imagelabels=image1,image2
                                -F "metadata=lastname:Smith,fullname:\"John Smith, Jr\""

    Media Server adds the face to the database and returns the identifier.