DataQ - Smart Tag Service

Updated at:

DataQ - Smart Tag Service analyzes visual, text, speech, and behavioral information in videos. It uses multimodal information fusion and alignment technology to recognize content with high accuracy. The service automatically outputs multi-dimensional content tags for videos, converting unstructured information into a structured format. You can use this service for scenarios such as media asset retrieval, personalized recommendations, and intelligent ad delivery. This topic provides sample code for using DataQ - Smart Tag Service with the ApsaraVideo Media Processing software development kit (SDK) for Java V2.0.

Version guide

The Java SDK for ApsaraVideo Media Processing must be version 2.7.6 or later. If you use Maven to manage Java dependencies, you can add the following dependency to the pom.xml file in your project.

<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>alibabacloud-mts20140618</artifactId>
  <version>3.0.0</version>
</dependency>

Prerequisites

An SDK client is initialized. For more information, see Initialize a client.

Submit a smart tagging job

Call the SubmitSmarttagJob operation to submit a smart tagging job. For more information about the fields and parameters of the operation, see SubmitSmarttagJob. The following sample code shows how to call the operation:

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * description :
     * <p>Initialize the client with an AccessKey pair.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.SubmitSmarttagJobRequest submitSmarttagJobRequest = new com.aliyun.mts20140618.models.SubmitSmarttagJobRequest()
                // The MPS queue ID. This parameter is required.
                .setPipelineId("2")
                // The video title. This parameter is required.
                .setTitle("example-title-****")
                // The URL of the video or image file to be analyzed. This parameter is required.
                .setInput("oss://mybucket-****/example-****.mp4")
                // The video content description.
                .setContent("example content ****")
                // The extra request parameters.
                .setParams("false")
                // The callback path.
                .setNotifyUrl("https://example.com/endpoint/aliyun/ai?id=76401125000***")
                // The information that is passed through the callback.
                .setUserData("{\"key\":\"value\"}")
                // The template ID used to specify the analysis algorithm.
                .setTemplateId("39f8e0bc005e4f309379701645f4****")
                // The priority of the job in the MPS queue.
                .setPriority("5");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy the code to run, print the return value of the API.
            client.submitSmarttagJobWithOptions(submitSmarttagJobRequest, runtime);
        } catch (TeaException error) {
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Query a smart tagging job

Call the QuerySmarttagJob operation to query a smart tagging job. For more information about the fields and parameters of the operation, see QuerySmarttagJob. The following sample code shows how to call the operation:

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * description :
     * <p>Initialize the client with an AccessKey pair.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.QuerySmarttagJobRequest querySmarttagJobRequest = new com.aliyun.mts20140618.models.QuerySmarttagJobRequest()
                // The ID of the smart tagging job that you want to query. This parameter is required.
                .setJobId("39f8e0bc005e4f309379701645f4****")
                // The extra request parameters.
                .setParams("{\"labelResultType\":\"auto\"}");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy the code to run, print the return value of the API.
            client.querySmarttagJobWithOptions(querySmarttagJobRequest, runtime);
        } catch (TeaException error) {
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Add template

Call the AddSmarttagTemplate operation to add a template. For more information about the fields and parameters of the operation, see AddSmarttagTemplate. The following sample code shows how to call the operation:

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * description :
     * <p>Initialize the client with an AccessKey pair.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.AddSmarttagTemplateRequest addSmarttagTemplateRequest = new com.aliyun.mts20140618.models.AddSmarttagTemplateRequest()
                // The custom template name. This parameter is required.
                .setTemplateName("template-example-****")
                // The industry of the file to be analyzed. This parameter is required.
                .setIndustry("common")
                // The scenario where the file to be analyzed is used. This parameter is required.
                .setScene("search")
                // The analysis type. This parameter is required.
                .setAnalyseTypes("ocr")
                // The IDs of the face libraries used for recognition.
                .setFaceCategoryIds("celebrity")
                // The parameters of the face algorithm.
                .setFaceCustomParamsConfig("{ \"faceDetThreshold\":0.999, \"faceRegThreshold\":0.9 }")
                // The IDs of the object libraries used for recognition.
                .setObjectGroupIds("general,item,weapon,animal")
                // The IDs of the location libraries used for recognition.
                .setLandmarkGroupIds("common")
                // Specifies whether to set the template as the default template. If you set this parameter to true, the template is used for transcoding when no transcoding template is specified. Valid values: true and false. The default value is false. Each Alibaba Cloud account can have only one default template. An error is reported if you set this parameter to true for multiple templates.
                .setIsDefault(true)
                // The annotation type.
                .setLabelType("hmi")
                // The version of DataQ - Smart Tag Service.
                .setLabelVersion("1.0")
                // For DataQ - Smart Tag Service 2.0 and 2.0-custom modes.
                .setKnowledgeConfig("{ \"movie\":\"name,alias,chnl,genre\", \"music\":\"songName,artistName\", \"person\":\"name,gender\" }")
                // The keyword tag configuration.
                .setKeywordConfig("\"type\": \"name,location,organization,other\" }");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy the code to run, print the return value of the API.
            client.addSmarttagTemplateWithOptions(addSmarttagTemplateRequest, runtime);
        } catch (TeaException error) {
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Query templates

Call the QuerySmarttagTemplateList operation to query template information. For more information about the fields and parameters of the operation, see QuerySmarttagTemplateList. The following sample code shows how to call the operation:

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * description :
     * <p>Initialize the client with an AccessKey pair.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.QuerySmarttagTemplateListRequest querySmarttagTemplateListRequest = new com.aliyun.mts20140618.models.QuerySmarttagTemplateListRequest()
                // The template ID.
                .setTemplateId("05de22f255284c7a8d2aab535dde****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy the code to run, print the return value of the API.
            client.querySmarttagTemplateListWithOptions(querySmarttagTemplateListRequest, runtime);
        } catch (TeaException error) {
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Update template

Call the UpdateSmarttagTemplate operation to update a template. For more information about the fields and parameters of the operation, see UpdateSmarttagTemplate. The following sample code shows how to call the operation:

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * description :
     * <p>Initialize the client with an AccessKey pair.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.UpdateSmarttagTemplateRequest updateSmarttagTemplateRequest = new com.aliyun.mts20140618.models.UpdateSmarttagTemplateRequest()
                // The template ID. This parameter is required.
                .setTemplateId("05de22f255284c7a8d2aab535dde****")
                // The custom template name.
                .setTemplateName("template-example-****")
                // The industry of the file to be analyzed.
                .setIndustry("common")
                // The scenario.
                .setScene("search")
                // The analysis type.
                .setAnalyseTypes("ocr,asr")
                // The IDs of the face libraries used for recognition.
                .setFaceCategoryIds("celebrity")
                // The parameters of the face algorithm.
                .setFaceCustomParamsConfig("{ \"faceDetThreshold\":0.999, \"faceRegThreshold\":0.9 }")
                // The IDs of the object libraries used for recognition.
                .setObjectGroupIds("general,item,weapon,animal")
                // The IDs of the location libraries used for recognition.
                .setLandmarkGroupIds("common")
                // Specifies whether the template is the default template.
                .setIsDefault(true)
                // The annotation type.
                .setLabelType("hmi")
                // The version of DataQ - Smart Tag Service.
                .setLabelVersion("1.0")
                // For DataQ - Smart Tag Service 2.0 and 2.0-custom modes.
                .setKnowledgeConfig("{ \"movie\":\"name,alias,chnl,genre\", \"music\":\"songName,artistName\", \"person\":\"name,gender\" }")
                // The keyword tag configuration.
                .setKeywordConfig("{ \"type\": \"name,location,organization,other\" }");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy the code to run, print the return value of the API.
            client.updateSmarttagTemplateWithOptions(updateSmarttagTemplateRequest, runtime);
        } catch (TeaException error) {
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Delete a template

Call the DeleteSmarttagTemplate operation to delete a template. For more information about the fields and parameters of the operation, see DeleteSmarttagTemplate. The following sample code shows how to call the operation:

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * description :
     * <p>Initialize the client with an AccessKey pair.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.DeleteSmarttagTemplateRequest deleteSmarttagTemplateRequest = new com.aliyun.mts20140618.models.DeleteSmarttagTemplateRequest()
                // The ID of the template to be deleted.
                .setTemplateId("05de22f255284c7a8d2aab535dde****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy the code to run, print the return value of the API.
            client.deleteSmarttagTemplateWithOptions(deleteSmarttagTemplateRequest, runtime);
        } catch (TeaException error) {
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Register a custom face

Call the RegisterCustomFace operation to register a custom face. For more information about the fields and parameters of the operation, see RegisterCustomFace. The following sample code shows how to call the operation:

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * description :
     * <p>Initialize the client with an AccessKey pair.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.RegisterCustomFaceRequest registerCustomFaceRequest = new com.aliyun.mts20140618.models.RegisterCustomFaceRequest()
                // The figure library ID. This parameter is required.
                .setCategoryId("CategoryId001-****")
                // The figure ID. This parameter is required.
                .setPersonId("PersonId001-****")
                // The public URL of the face image to be registered. This parameter is required.
                .setImageUrl("http://example-****.jpeg");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy the code to run, print the return value of the API.
            client.registerCustomFaceWithOptions(registerCustomFaceRequest, runtime);
        } catch (TeaException error) {
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Deregister a custom face

Call the UnregisterCustomFace operation to unregister a custom face. For more information about the fields and parameters of the operation, see UnregisterCustomFace. The following sample code shows how to call the operation:

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * description :
     * <p>Initialize the client with an AccessKey pair.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.UnregisterCustomFaceRequest unregisterCustomFaceRequest = new com.aliyun.mts20140618.models.UnregisterCustomFaceRequest()
                // The figure library ID. This parameter is required.
                .setCategoryId("CategoryId001-****")
                // The figure ID. This parameter is required.
                .setPersonId("PersonId001-****")
                // The face ID. This parameter is required.
                .setFaceId("15****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy the code to run, print the return value of the API.
            client.unregisterCustomFaceWithOptions(unregisterCustomFaceRequest, runtime);
        } catch (TeaException error) {
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Add a custom figure library or figure tag

Call the TagCustomPerson operation to add a custom figure library or figure tag. For more information about the fields and parameters of the operation, see TagCustomPerson. The following sample code shows how to call the operation:

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * description :
     * <p>Initialize the client with an AccessKey pair.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.TagCustomPersonRequest tagCustomPersonRequest = new com.aliyun.mts20140618.models.TagCustomPersonRequest()
                // The figure library ID.
                .setCategoryId("CategoryId001-****")
                // The figure library name.
                .setCategoryName("CategoryNametest-****")
                // The figure library description.
                .setCategoryDescription("CategoryDescription001-****")
                // The figure ID.
                .setPersonId("PersonId001-****")
                // The figure name.
                .setPersonName("PersonNametest-****")
                // The figure description.
                .setPersonDescription("PersonDescriptiontest-****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy the code to run, print the return value of the API.
            client.tagCustomPersonWithOptions(tagCustomPersonRequest, runtime);
        } catch (TeaException error) {
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

List all figures and faces in a figure library

Call the ListCustomPersons operation to list all figures and faces in a figure library. For more information about the fields and parameters of the operation, see ListCustomPersons. The following sample code shows how to call the operation:

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * description :
     * <p>Initialize the client with an AccessKey pair.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.ListCustomPersonsRequest listCustomPersonsRequest = new com.aliyun.mts20140618.models.ListCustomPersonsRequest()
                // The figure library ID.
                .setCategoryId("CategoryId-****")
                // The figure ID.
                .setPersonId("PersonId-****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy the code to run, print the return value of the API.
            client.listCustomPersonsWithOptions(listCustomPersonsRequest, runtime);
        } catch (TeaException error) {
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // The following code is for demonstration purposes only. We recommend that you handle exceptions with caution and do not ignore them in your projects.
            // Error message
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}