# TrainImageComparisonReference

Trains Media Server to identify changes to an image. This adds a new reference, with a training image, to an image comparison database.

This action is atomic, so that any interruption to the server does not leave the database in an inconsistent state. The database is not modified if the action returns an error, or if you stop it using the QueueInfo action. If the training images fail, Media Server does not add the reference to the database.

Type: asynchronous

Parameter | Description | Required
--- | --- | ---
`database` | The name of the database to add the new image comparison reference to. The database must already exist. | Yes
`identifier` | A unique identifier for the reference (maximum 254 bytes). If you do not set this parameter, Media Server generates an identifier automatically. | No
`imagedata` | The training image to add. Files must be uploaded as multipart/form-data. For more information about sending data to Media Server, refer to the Media Server Administration Guide. | Set this or `imagepath`
`imagelabels` | A label to identify the image that you are adding (maximum 254 bytes). If you do not set this parameter, Media Server generates a label automatically. | No
`imagepath` | The path to the training image to add. The path must be absolute, or relative to the Media Server executable file. | Set this or `imagedata`
`metadata` | A comma-separated list of metadata key-value pairs to add to the reference. Separate keys from values using a colon (`:`). To include a comma or colon in a key name or value, enclose the key name or value in quotation marks (`"`) and escape any quotation marks that occur within the string with a backslash (`\`). | No
`numparallel` | The maximum number of threads that the action can use (default 1). | No

## Example

The following example trains Media Server by sending the path of a training image using the `imagepath` parameter:

    curl http://localhost:14000 -F action=TrainImageComparisonReference
                                -F database=ReferenceImages
                                -F identifier=toolkit
                                -F imagepath=toolkit1.png
                                -F imagelabels=image1
                                -F "metadata=PartNumber:8572087,\"another:value\":\"1,000\""

Alternatively, you can train Media Server by sending the image data, for example:

    curl http://localhost:14000 -F action=TrainImageComparisonReference
                                -F database=ReferenceImages
                                -F identifier=toolkit
                                -F imagedata=@toolkit1.png
                                -F imagelabels=image1
                                -F "metadata=PartNumber:8572087,\"another:value\":\"1,000\""

## Response

This action is asynchronous, so Media Server always returns success accompanied by a token:

    <autnresponse>
      <action>TRAINIMAGECOMPARISONREFERENCE</action>
      <response>SUCCESS</response>
      <responsedata>
        <token>MTAuMi4xMDQuNTQ6MTgwMDA6VFJBSU5GQUNFOjE0MjkyNzE0NjAwMDQ1Ni0xMzAyMzQ3MDI2</token>
      </responsedata>
    </autnresponse>

You can use this token with the QueueInfo action to retrieve the status of the action:

    <autnresponse>
      <action>QUEUEINFO</action>
      <response>SUCCESS</response>
      <responsedata>
        <actions>
          <action>
            <status>Finished</status>
            <queued_time>2015-Jun-04 09:53:21</queued_time>
            <time_in_queue>0</time_in_queue>
            <process_start_time>2015-Jun-04 09:53:21</process_start_time>
            <time_processing>0</time_processing>
            <process_end_time>2015-Jun-04 09:53:21</process_end_time>
            <build>
              <image>
                <index>1</index>
                <label>image1</label>
                <status>trained</status>
              </image>
            </build>
            <database>ReferenceImages</database>
            <identifier>toolkit</identifier>
            <numimages>1</numimages>
            <numtrained>1</numtrained>
            <token>MTAuMi4xMDQuNTQ6MTgwMDA6VFJBSU5GQUNFOjE0MjkyNzE0NjAwMDQ1Ni0xMzAyMzQ3MDI2</token>
          </action>
        </actions>
      </responsedata>
    </autnresponse>

© Copyright 2020 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm