Updated on 2022-03-31 GMT+08:00

Quick Start

Environment Preparation

  1. Enable the Face Recognition service: Log in to the Face Recognition management console, select a sub-service, and click Enable Service on the right.

    You only need to enable the service once.

  2. Obtain the endpoints of Face Recognition. For details, see Regions and Endpoints.
  3. For details about Face Recognition APIs, see the Face Recognition API Reference.
  4. Obtain the AK/SK of your HUAWEI CLOUD account.

    If no AK/SK has been generated, log in to , enter the My Credentials page, and choose Access Keys > Create Access Key to obtain the access keys.

  1. Install the JDK. The Java SDK can run on JDK 1.8 or later.
  • SDKs provided by Face Recognition do not support access retries. If the access is abnormal, the SDK directly returns the request results. Therefore, the client needs to establish a retry mechanism.
  • When an Android system uses this Java SDK, the main thread is not supported. You are advised to use the sub-thread.
  • When using the demo in the Java SDK, you are advised to use JDK 1.9+ because readAllBytes() is a method in JDK 1.9+.
  • For details about how to use the demo in the SDK, see demoV2().

SDK Acquisition and Installation

Take Eclipse as an example. After creating a Java project, perform the following steps to import the JAR file to the new project:

  1. Download the SDK JAR file.
  2. Copy the downloaded JAR file to the project folder.
  3. Open the project in Eclipse, right-click the project, and choose Properties.
  4. In the displayed dialog box, click Java Build Path. On the Libraries tab, click Add JARs to add the downloaded JAR file.
  5. Click OK.

Services involved in this document use the same JAR file.