Add an Object to a Database (Using a Single Action)

You can train Media Server to recognize an object by sending a single action (TrainObject).

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

  • NewObject
  • AddObjectImages
  • SetObjectTrainingOption (optional)
  • AddObjectMetadata (optional)
  • BuildObject

The TrainObject 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 an Object to a Database (Using Separate Steps).

To add an object to a database (using a single action)

  • Add an object using the TrainObject action. For example:

    curl http://localhost:14000/action=TrainObject -F database=CompanyLogos -F identifier=AcmeCo -F imagedata=@logo.png -F "metadata=category:software,\"another:value\":\"1000\"" -F trainingoptions=useColor:true,3D:false

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

    curl http://localhost:14000/action=TrainObject -F database=CompanyLogos -F identifier=AcmeCo -F imagepath=logo.png -F "metadata=category:software,\"another:value\":\"1000\"" -F trainingoptions=useColor:true,3D:false

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