Media Server 24.2

# Add an Object to a Database (Using Separate Steps)

This section describes how to create a new (empty) object, then add training images, and then train Media Server, using separate actions. You can also add metadata to the object, and configure training options, but these are optional steps. 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 an object by sending a single action. To do this, see Add an Object to a Database (Using a Single Action).

To add an object to a database (using separate steps)

1. Add an object using the `NewObject` action. Set the following parameters:

   `database` | The name of the database to add the object to. The database must already exist.
   `identifier` | (Optional) A unique identifier for the object (maximum 254 bytes). If you do not set this parameter, Media Server generates an identifier automatically.

   For example:

       curl http://localhost:14000 -F action=NewObject
                                   -F database=CompanyLogos

   Media Server adds an object to the database and returns the identifier.

2. Add one or more training images to the object using the `AddObjectImages` action. Set the following parameters:

   `database` | The name of the database that contains the object.
   `identifier` | The identifier for the object, returned by the `NewObject` action.
   `imagedata` | (Set this or `imagepath`, but not both). The training images to add. Files must be uploaded as multipart/form-data. For more information about sending data to Media Server, see Send Data by Using a POST Method.
   `imagepath` | (Set this or `imagedata`, but not both). The paths of the training images to add. The paths must be absolute or relative to the Media Server executable file.
   `imagelabels` | A comma-separated list of labels. One label is associated with each image. (maximum 254 bytes for each label). The number of labels must match the number of images. If you do not set this parameter, Media Server generates labels automatically.

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

       curl http://localhost:14000 -F action=AddObjectImages
                                   -F database=CompanyLogos
                                   -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62
                                   -F imagedata=@logo1.png

   Alternatively, to add a training image by supplying its path:

       curl http://localhost:14000 -F action=AddObjectImages
                                   -F database=CompanyLogos
                                   -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62
                                   -F imagepath=logo1.png

3. (Optional) Configure the way that Media Server is trained by setting training options for the object. To do this use the `SetObjectTrainingOption` action with the following parameters:

   `database` | The name of the database that contains the object.
   `identifier` | The identifier for the object, returned by the `NewObject` action.
   `key` | The name of the training option that you want to change. For more information about training options, see Object Training Options.
   `value` | The new value for the training option.

   For example:

       curl http://localhost:14000 -F action=SetObjectTrainingOption
                                   -F database=CompanyLogos
                                   -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62
                                   -F key=useColor
                                   -F value=true

4. (Optional) Add metadata to the object using the `AddObjectMetadata` action. You can add any number of key-value pairs. Set the following parameters:

   `database` | The name of the database that contains the object.
   `identifier` | The identifier for the object, returned by the `NewObject` action.
   `key` | The key to add (maximum 254 bytes).
   `value` | The value to add (maximum 254 bytes).

   For example:

       curl http://localhost:14000 -F action=AddObjectMetadata
                                   -F database=CompanyLogos
                                   -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62
                                   -F key=CompanyName
                                   -F value=HewlettPackard

5. Complete the training for the object using the `BuildObject` action. Set the following parameters:

   `database` | The name of the database that contains the object.
   `identifier` | The identifier for the object, returned by the `NewObject` action.

   For example:

       curl http://localhost:14000 -F action=BuildObject
                                   -F database=CompanyLogos
                                   -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62

Copyright 2024 Open Text
Version 24.2 | Last updated March 2024

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: IDOL Media Server 24.2

Topic Title: Add an Object to a Database (Using Separate Steps)