Add a Face to a Database (Using Separate Steps)

This section describes how to create a new (empty) face, then add training images, and then train Media Server, using separate actions. You can also add metadata to the face but this is an optional step. You might want to perform training in this way if you are building a front end application that responds to user input.

Alternatively, you can train Media Server to recognize a face by sending a single action. To do this, see Add a Face to a Database (Using a Single Action).

To add a face to a database (using separate steps)

  1. Add a face using the NewFace action. For example:

    curl http://localhost:14000/action=NewFace -F database=Faces

    Media Server adds the face and returns the identifier.

  2. Add one or more training images to the face using the AddFaceImages action.

    For example, to add training images by supplying the image data:

    curl http://localhost:14000/action=AddFaceImages
                                -F database=Faces
                                -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62
                                -F imagedata=@face1_smile.jpg,face1_neutral.jpg
                                -F imagelabels=image1,image2

    Alternatively, to add training images by supplying their paths:

    curl http://localhost:14000/action=AddFaceImages
                                -F database=Faces
                                -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62
                                -F imagepath=face1_smile.jpg,face1_neutral.jpg
                                -F imagelabels=image1,image2
  3. (Optional) Add metadata to the face using the AddFaceMetadata action. You can add any number of key-value pairs. For example:

    curl http://localhost:14000/action=AddFaceMetadata
                                -F database=Faces
                                -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62
                                -F key=firstname
                                -F value=John
  4. Complete the training for the face using the BuildFace action. For example:

    curl http://localhost:14000/action=BuildFace 
                                -F database=Faces
                                -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62