api reference · image recognition api reference issue 04 date 2018-07-16 huawei technologies co.,...

48
Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD.

Upload: others

Post on 07-Aug-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Image Recognition

API Reference

Issue 04

Date 2018-07-16

HUAWEI TECHNOLOGIES CO., LTD.

Page 2: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Copyright © Huawei Technologies Co., Ltd. 2018. All rights reserved.No part of this document may be reproduced or transmitted in any form or by any means without prior writtenconsent of Huawei Technologies Co., Ltd. Trademarks and Permissions

and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.All other trademarks and trade names mentioned in this document are the property of their respectiveholders. NoticeThe purchased products, services and features are stipulated by the contract made between Huawei and thecustomer. All or part of the products, services and features described in this document may not be within thepurchase scope or the usage scope. Unless otherwise specified in the contract, all statements, information,and recommendations in this document are provided "AS IS" without warranties, guarantees orrepresentations of any kind, either express or implied.

The information in this document is subject to change without notice. Every effort has been made in thepreparation of this document to ensure accuracy of the contents, but all statements, information, andrecommendations in this document do not constitute a warranty of any kind, express or implied.

Huawei Technologies Co., Ltd.Address: Huawei Industrial Base

Bantian, LonggangShenzhen 518129People's Republic of China

Website: http://e.huawei.com

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

i

Page 3: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Contents

1 API Calling..................................................................................................................................... 11.1 Applying for a Service....................................................................................................................................................11.2 Service Usage................................................................................................................................................................. 21.3 Token Authentication......................................................................................................................................................41.4 AK/SK Authentication................................................................................................................................................... 8

2 Image Recognition APIs.............................................................................................................142.1 Image Tagging.............................................................................................................................................................. 142.2 Recapture Detection..................................................................................................................................................... 172.3 Dark Enhance............................................................................................................................................................... 202.4 Defog............................................................................................................................................................................ 232.5 Super Resolution...........................................................................................................................................................26

3 Service Management APIs.........................................................................................................303.1 Enabling Image Recognition........................................................................................................................................ 303.2 Querying the Service Enabling Status.......................................................................................................................... 323.3 Querying Service Calling Times...................................................................................................................................34

A Appendix......................................................................................................................................37A.1 Common Message Headers......................................................................................................................................... 37A.2 Status Code.................................................................................................................................................................. 39A.3 Error Code................................................................................................................................................................... 42

B Change History............................................................................................................................45

Image RecognitionAPI Reference Contents

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

ii

Page 4: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

1 API Calling

API requests sent by third-party applications to HUAWEI CLOUD must be authenticatedusing signatures.

This chapter describes the overall method of using signatures and provides sample code todetail how to use the default signer to sign requests and how to use an HTTP client to sendrequests.

1.1 Applying for a ServiceBefore using Image Recognition, you must apply for your desired services of ImageRecognition. The following is the procedure for applying for services of Image Recognition.

NOTE

1. Before applying for any service of Image Recognition, apply for a HUAWEI CLOUD account andcomplete real-name authentication.

2. If you use Image Recognition for the first time, apply for your desired services first. You only needto apply for a service once.

Step 1 Log in to HUAWEI CLOUD and click Console in the upper right corner. The Console page isdisplayed.

Step 2 Click Service List and choose EI Enterprise Intelligence > Image Recognition. The ImageRecognition management console is displayed.

Step 3 On the Commercial Services or Beta Services tab page, find out your desired services. Fordetails about how to apply for a beta service, go to Step 4. For details about how to apply fora commercial service, go to Step 5.

Step 4 Click Apply for Open Beta Test.

NOTE

l To apply for multiple beta services at the same time, select your desired services and click BatchApply for Open Beta Test.

l The OBT application is manually reviewed. Generally, it takes one to two days for approval. In thecase of holidays, the approval may take longer.

Step 5 Click Apply for Service.

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

1

Page 5: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Step 6 After the OBT or service application is approved, the service is enabled.

----End

1.2 Service UsageHUAWEI CLOUD APIs comply with RESTful API design specifications. RepresentationalState Transfer (REST) allocates Uniform Resource Identifiers (URIs) to dispersed resourcesso that the resources can be located. Applications on clients use Uniform Resource Locators(URLs) to obtain the resources.

This section describes the following contents:

l Structure of RESTful API Requests and Responsesl Request Authentication Methodsl Request Sending

Structure of RESTful API Requests and Responses

A RESTful API request or response consists of the following five parts:

l Request URLThe URL format is https://Endpoint/uri. Table 1-1 describes the parameters in a URL.

Table 1-1 Parameters in a URL

Parameter Description

Endpoint Indicates the URL that is the entry point for a web service.Obtain this value from Regions and Endpoints.Image Recognition uses the endpoint of Artificial IntelligenceService (AIS), that is, ais.cn-north-1.myhuaweicloud.com.

uri Indicates the API access path for performing a specifiedoperation. Obtain this value from the URI of the API, forexample, /v1.0/ais/subscribe.

l Request headerA request header consists of the following two parts:– HTTP method. Table 1-2 describes the HTTP methods supported by the RESTful

APIs.

Table 1-2 HTTP methods

Method Description

GET The GET method requests a representation of the specifiedresource.

PUT The PUT method requests that the enclosed entity be stored underthe supplied URI.

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

2

Page 6: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Method Description

POST The POST method requests that the server accept the entityenclosed in the request as a new subordinate of the web resourceidentified by the URI.

DELETE The DELETE method deletes the specified resource, for example,an object.

PATCH The PATCH method applies partial modifications to a resource.If the target resource does not exist, PATCH may create aresource.

– (Optional) Additional fields in the request header required by a specific URI andHTTP method. For details about common request headers, see Common RequestHeaders.

l Request body

A request body is generally sent in a structured format (for example, JSON or XML),corresponding to Content-Type in the request header, and is used to transfer contentother than the request header.

If the request body contains Chinese characters, convert the Chinese characters into theUTF-8 encoding format.

l Response header

A response header consists of the following two parts:

– Status code, from 2xx success code to 4xx or 5xx error code. For details about thestatus code, see A.2 Status Code.

– Additional fields in the response header required by a specific response, forexample, the Content-Type response header. For details about common responseheaders, see Common Response Headers.

l Response body

A response body is generally returned in a structured format (for example, JSON orXML), and is used to transfer content other than the response header.

– When a service request succeeds, the service request result is returned.

– When a service request fails, an error code is returned. For details about the errorcode, see A.3 Error Code.

Request Authentication Methods

You can use either of the following authentication methods when making an API call:

l Token authentication: Requests are authenticated using tokens.

l AK/SK authentication: Requests are encrypted using the access key ID (AK) and secretaccess key (SK) to provide higher security.

Request Sending

You can send a request based on the constructed request body using any of the following threemethods:

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

3

Page 7: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

l cURL

cURL is a command-line tool used to perform URL operations and transfer information.It serves as the HTTP client that can send HTTP requests to the HTTP server and receiveresponse messages. cURL is suitable for use in API tuning scenarios. For moreinformation about cURL, visit https://curl.haxx.se/.

l Code

You can invoke APIs using code to assemble, send, and process request messages.

l REST client

Both Mozilla and Google provide a graphical browser plug-in, that is, REST client, tosend and process requests.

– For Mozilla Firefox, see Firefox REST Client.

– For Google Chrome, see Postman Interceptor.

1.3 Token Authentication

Scenarios

To use token authentication, obtain the user token, and add X-Auth-Token to the requestheader of the service API when making an API call.

This section describes how to make an API call using token authentication.

Procedure

Step 1 Send a POST request to https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens.

Parameter Content-Type: application/json needs to be added to the request header to ensurethat the request can be processed correctly by the service.

A sample request is as follows:{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", //Username "password": "password", //Password "domain": { "name": "domainname" //Account name } } } }, "scope": { "project": { "name": "cn-north-1" //Image Recognition is enabled in CN North-Beijing1, so the default value is cn-north-1. } } }}

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

4

Page 8: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

NOTE

To obtain the username and account name in the preceding sample code, do as follows:

1. Log in to HUAWEI CLOUD, hover the cursor on the username in the upper right corner, and selectMy Account from the drop-down list. The Account Info page is displayed.

2. Click Manage. On the My Credential page that is displayed, check Username and Account Name.The password is that of the current user.

3. For project, see the name of the valid project in the project list. The default project is cn-north-1.

Step 2 Obtain the token. The token value is the X-Subject-Token value in the response header.

Step 3 Invoke a service API, add X-Auth-Token to the request header, and set the value of X-Auth-Token to the token obtained in Step 2.

----End

Examplesl cURL

a. Create the data.json file. The following shows the content of the file, in which youneed to change username, password, and domainname as required.{ "auth": { "identity": { "password": { "user": { "name": "username", "password": "password", "domain": { "name": "domainname" } } }, "methods": [ "password" ] }, "scope": { "project": { "name": "cn-north-1" } }

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

5

Page 9: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

}}

b. Run the following command to obtain the token. The header.txt file is created inthe current directory.curl -X POST https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens --header 'content-type: application/json' -d "@data.json" -D header.txt

c. Open the header.txt file. The following information is displayed. The value of X-Subject-Token is the obtained token.HTTP/1.1 201 Created...Transfer-Encoding: chunkedConnection: keep-aliveX-Iam-Trace-Id: ed91b739-783X-409e-96cc-74573adf027aX-Subject-Token: MIIMkgYJKoZIhvcNAQcCoIIM...Strict-Transport-Security: max-age=31536000; includeSubdomains;...

d. Run the following command to invoke the service (check whether ImageRecognition is enabled). Set x-auth-token to the token obtained in the previousstep.curl -X GET https://ais.cn-north-1.myhuaweicloud.com/v1.0/ais/subscribe?service_type=image_tagging --header 'x-auth-token: MIIMkgYJK...'

l Javapackage com.huawei.ais.demo; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.FileBody; import org.apache.http.message.BasicHeader; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.huawei.ais.sdk.util.HttpClientUtils; /** * Access the service using token authentication. */ public class TokenDemo { /** * Create a token object that accesses the service using token authentication. * * @param username Username * @param password Password * @param domainName Domain name * @param projectName Project name * @return Construct the JSON object of the access. */ private static String requestBody(String username, String passwd, String domainName, String projectName) { JSONObject auth = new JSONObject(); JSONObject identity = new JSONObject(); JSONArray methods = new JSONArray();

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

6

Page 10: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

methods.add("password"); identity.put("methods", methods); JSONObject password = new JSONObject(); JSONObject user = new JSONObject(); user.put("name", username); user.put("password", passwd); JSONObject domain = new JSONObject(); domain.put("name", username); user.put("domain", domain); password.put("user", user); identity.put("password", password); JSONObject scope = new JSONObject(); JSONObject scopeProject = new JSONObject(); scopeProject.put("name", projectName); JSONObject projectDomain = new JSONObject(); projectDomain.put("name", domainName); scopeProject.put("domain", projectDomain); scope.put("project", scopeProject); auth.put("identity", identity); auth.put("scope", scope); JSONObject params = new JSONObject(); params.put("auth", auth); return params.toJSONString(); } /** * Obtain the token parameter. Note that this function aims to extract the token from the header in the HTTP request response body. * The parameter name is X-Subject-Token. * * @param username Username * @param password Password * @param projectName Region name. For details, see https://developer.huaweicloud.com/en-us/endpoint. * @return Response body containing the token string * @throws URISyntaxException * @throws UnsupportedOperationException * @throws IOException */ private static String getToken(String username, String password, String projectName) throws URISyntaxException, UnsupportedOperationException, IOException { String requestBody = requestBody(username, password, username, projectName); String url ="https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens"; Header[] headers = new Header[] { new BasicHeader("Content-Type", ContentType.APPLICATION_JSON.toString()) }; StringEntity stringEntity = new StringEntity(requestBody, "utf-8"); HttpResponse response = HttpClientUtils.post(url, headers, stringEntity); Header[] xst = response.getHeaders("X-Subject-Token"); return xst[0].getValue(); }

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

7

Page 11: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

/** * Use the file encoded by Base64 and access the service using token authentication. * @param token Token authentication string * @param formFile File path * @throws IOException */ public static void requestImageTaggingBase64(String token, String formFile) throws IOException { String url = "https://ais.cn-north-1.myhuaweicloud.com/v1.0/image/tagging"; Header[] headers = new Header[] {new BasicHeader("X-Auth-Token", token) ,new BasicHeader("Content-Type", "application/json")}; String requestBody=toBase64Str(formFile); StringEntity stringEntity = new StringEntity(requestBody, "utf-8"); try { HttpResponse response = HttpClientUtils.post(url, headers, stringEntity); System.out.println(response); String content = IOUtils.toString(response.getEntity().getContent()); System.out.println(content); } catch (Exception e) { e.printStackTrace(); } } /** * Convert binary files into access request objects (JSON string format) encoded by Base64. * * @param file File name * @return Contain the JSON object in file character stream after Base64 encoding. * @throws IOException */ public static String toBase64Str(String file) throws IOException{ byte[] fileData = FileUtils.readFileToByteArray(new File(file)); String fileBase64Str = Base64.encodeBase64String(fileData); JSONObject json = new JSONObject(); json.put("image", fileBase64Str); return json.toJSONString(); } /** * Invoke the main entrypoint function. */ public static void main(String[] args) throws URISyntaxException, UnsupportedOperationException, IOException { String username = "zhangshan"; // Enter the username. String password = "*******"; // Enter the corresponding password. String regionName = "cn-north-1"; // Enter the region where the service is available. For details, visit https://developer.huaweicloud.com/en-us/endpoint. String token = getToken(username, password, regionName); System.out.println(token); requestImageTaggingBase64(token, "data/image-tagging-demo-1.jpg"); } }

1.4 AK/SK AuthenticationWhen you use the API gateway to send requests to underlying services, the requests aresigned using the AK and SK.

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

8

Page 12: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

NOTE

AK: indicates the ID of the access key. It is the unique identifier associated with the SK. The AK andSK are used together to obtain an encrypted signature for a request.SK: indicates the secret access key used together with the AK to sign requests. The AK and SK are usedtogether to identify a request sender to prevent the request from being modified.

Obtaining the AK/SK1. Log in to HUAWEI CLOUD, hover the cursor on the username in the upper right corner,

and select My Account from the drop-down list. The Account Info page is displayed.2. Click Manage. On the My Credential page that is displayed, click the Access Keys tab.3. Click Add Access Key. The Add Access Key dialog box is displayed.4. Input the login password of the current user and enter the verification code received in

the email or on the mobile phone.

NOTE

For users created in Identity and Access Management (IAM), if no email address or mobile phonenumber is filled in during the user creation, you only need to verify the login password.

5. Click OK to download the access key.

NOTE

To prevent the access key from being leaked, keep it secure.

Invoking a Requestl Preparations

a. Download the software development kit (SDK) and related documents from theHUAWEI CLOUD official website.The link is as follows: https://developer.huaweicloud.com/en-us/sdk?IMAGE

b. Decompress the downloaded file.c. Import the decompressed Java project to the Java integrated development

environment (IDE).

NOTE

l Because HTTPS authentication is involved, the Java version must be 1.8. Therecommended version is 1.8.0.131 or later.

l You are advised to use Eclipse or IDEA.

l Request Invoking Process

a. Create request com.huawei.ais.sdk.AisAccess(JAVA) used for signing.b. Set basic information required by AisAccess, such as AK/SK, region, and endpoint.c. Fill in the URI, request header, and service parameters required for accessing the

service and then invoke the service.

NOTE

AisAccess has a built-in request signing process. Developers can ignore it.

Sample CodeThe following code shows how to sign a request and how to use AisAccess to send an HTTPSrequest:

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

9

Page 13: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

The code is classified into three classes for demonstration.

ClientContextUtils: specifies the tool class used to configure parameters such as AK and SKrequired by basic signature algorithms.

ResponseProcessUtils: specifies the tool class used to process the returned result.

ImageTaggingDemo: specifies an example of accessing Image Tagging.

ClientContextUtils.java

import com.huawei.ais.common.AuthInfo; import com.huawei.ais.common.ProxyHostInfo; /** * This is the tool function of the HTTP client and is used to initialize some general information of the client. * * Include endpoint, area, access key, and secret access key. * */ public class ClientContextUtils { private static final AuthInfo HEC_AUTH = new AuthInfo( /* Endpoint of AIS. The service port information can be obtained from the following website: * https://developer.huaweicloud.com/en-us/endpoint * */ "https://ais.cn-north-1.myhuaweicloud.com", "cn-north-1", /* Region information of AIS, which can be queried from the preceding website. */ "*********", /* Enter the AK. */ "********" /* Enter the SK corresponding to the AK. */ ); public static AuthInfo getAuthInfo() { return HEC_AUTH; } /** * Enable network access in proxy mode. The proxy host is used to configure the information. */ public static ProxyHostInfo getProxyHost() { return new ProxyHostInfo("proxy.example.com", /* Proxy host information */ 8080, /* Proxy host port */ "*******", /* Proxy name */ "*******" /* Password of the proxy user */ ); } }

ResponseProcessUtils.java

package com.huawei.ais.demo; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import org.apache.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.cloud.sdk.util.Base64; import com.huawei.ais.sdk.util.HttpClientUtils; /**

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

10

Page 14: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

* Tool class used to verify the information returned from service access */ public class ResponseProcessUtils { /** * Print the HTTP status code after the service access is complete. * * @param response Response object */ public static void processResponseStatus(HttpResponse response) { System.out.println(response.getStatusLine().getStatusCode()); } /** * Convert the service access result into a character stream, which is used for displaying the JSON data. * * @param response Response object * @throws UnsupportedOperationException * @throws IOException */ public static void processResponse(HttpResponse response) throws UnsupportedOperationException, IOException { System.out.println(HttpClientUtils.convertStreamToString(response.getEntity().getContent())); } /** * Create the Base64-encoded image file. * * @param response * @throws UnsupportedOperationException * @throws IOException */ public static void processResponseWithImage(HttpResponse response, String fileName) throws UnsupportedOperationException, IOException { String result = HttpClientUtils.convertStreamToString(response.getEntity().getContent()); JSONObject resp = JSON.parseObject(result); String imageString = (String)resp.get("result"); byte[] fileBytes = Base64.decode(imageString); writeBytesToFile(fileName, fileBytes); } /** * Write a byte array to a file to create a binary file (for example, an image). * @param fileName File name * @param data Data * @throws IOException */ public static void writeBytesToFile(String fileName, byte[] data) throws IOException{ FileChannel fc = null; try { ByteBuffer bb = ByteBuffer.wrap(data); fc = new FileOutputStream(fileName).getChannel(); fc.write(bb); } catch (Exception e) { e.printStackTrace(); System.out.println(e.getMessage()); } finally { fc.close(); }

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

11

Page 15: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

} }

ImageTaggingDemo.java

package com.huawei.ais.demo.image; import com.alibaba.fastjson.JSONObject; import com.huawei.ais.demo.ClientContextUtils; import com.huawei.ais.demo.ResponseProcessUtils; import com.huawei.ais.sdk.AisAccess; import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.FileUtils; import org.apache.http.HttpResponse; import org.apache.http.entity.StringEntity; import java.io.File; import java.io.IOException; /** * Example of using Image Tagging */ public class ImageTaggingDemo { // // Example function of using Image Tagging // private static void imageTaggingDemo() throws IOException { // // 1. In the ClientContextUtils class, configure basic information for accessing Image Tagging. // Then, a client connection object is generated. // AisAccess service = new AisAccess(ClientContextUtils.getAuthInfo()); // // 1.a Image Tagging can be accessed in proxy mode. It applies to the scenario where a user cannot directly access HUAWEI CLOUD services, for example, intranet. // If a proxy is used, you need to configure the parameter class (ProxyHostInfo) of the proxy server in ClientContextUtils. // //AisAccess service = new AisAccessWithProxy(ClientContextUtils.getAuthInfo(), ClientContextUtils.getProxyHost()); try { // // 2. Configure the parameters required for accessing Image Tagging. // String uri = "/v1.0/image/tagging"; byte[] fileData = FileUtils.readFileToByteArray(new File("data/image-tagging-demo-1.jpg")); String fileBase64Str = Base64.encodeBase64String(fileData); JSONObject json = new JSONObject(); json.put("image", fileBase64Str); json.put("threshold", 60); StringEntity stringEntity = new StringEntity(json.toJSONString(), "utf-8"); // 3. Pass the URI parameter corresponding to Image Tagging and parameters required by Image Tagging. // Pass the parameters in JSON objects and invoke the service using POST. HttpResponse response = service.post(uri, stringEntity); // 4. Check whether the service invocation is successful. If 200 is returned, the invocation succeeds. Otherwise, it fails. ResponseProcessUtils.processResponseStatus(response);

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

12

Page 16: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

// 5. Process the character stream returned by the service and output the recognition result. ResponseProcessUtils.processResponse(response); } catch (Exception e) { e.printStackTrace(); } finally { // 6. Disconnect the client connection. service.close(); } } // // Main entrypoint function // public static void main(String[] args) throws IOException { // Test entrypoint function imageTaggingDemo(); } }

Image RecognitionAPI Reference 1 API Calling

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

13

Page 17: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

2 Image Recognition APIs

This section uses token-based request headers as examples. You can use either token-based orAK/SK-based request headers as required in actual use.

NOTE

The token value in the sample request is the one obtained during application.

2.1 Image Tagging

FunctionNatural images have extensive semantic meanings because one image contains a wide varietyof tags. This API can be used to identify hundreds of scenarios and thousands of objects andtheir properties in natural images, making intelligent album management, picture retrieval andclassification, and scenario- or object-based advertising more intuitive. After you upload theimage to be processed, Image Tagging returns tags and confidence scores to you.

URIURI format

POST /v1.0/image/tagging

Requestl Sample request (Method 1: Use a Base64-encoded image.)

POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/image/tagging Request Header: Content-Type:application/jsonX-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...

Request Body:{ "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEe

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

14

Page 18: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

ARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj...", "url": "", "language": "en", "limit": 5, "threshold": 60.0}

l Sample request (Method 2: Use the URL redirecting to the image file.)POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/image/tagging Request Header: Content-Type:application/jsonX-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...

Request Body:{ "image":"", "url":"https://BucketName.obs.myhwclouds.com/ObjectName", "language": "zh", "limit": 5, "threshold": 60.0}

l Parameter description

Parameter Mandatory Type Description

image Configureeither thisparameter orurl.

String Indicates the Base64 character stringconverted from the image. The sizecannot exceed 10 MB. The imageresolution of the narrow sides mustbe greater than 15 pixels, and that ofthe wide sides cannot exceed 4096pixels. The supported image formatsinclude JPG, PNG, and BMP.

url Configureeither thisparameter orimage.

String Indicates the URL of the image file.Currently, URLs for temporarilyauthorized access and anonymouslyand publicly authorized access toimage files stored on OBS aresupported.

language No String Indicates the language of thereturned tag. Possible values are asfollows:l en: indicates that the tag content

is in English. It is the defaultvalue.

l zh: indicates that the tag contentis in Chinese.

limit No Integer Indicates the maximum number oftags that can be returned. The defaultvalue is -1, indicating that all tagsare returned.

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

15

Page 19: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Parameter Mandatory Type Description

threshold No Float Indicates the threshold (0 to 100) ofthe confidence score. The tagswhose confidence score is lowerthan the threshold will not bereturned.The default value is 0.

Responsel Sample response

{ "result":{ "tags":[ { "confidence": 38.51, "tag":"sky" }, { "confidence": 25.75, "tag":"landscape" } ] }}

l Failed sample response{ "error_code": "AIS.0005", "error_msg": "The service does not exist."}

l Parameter description

Parameter Type Description

result JSON Indicates the content of the image tag when the API issuccessfully called.This parameter is not included when the API fails tobe called.

tags List Indicates the list of tags.

confidence Float Indicates the confidence score. The value ranges from0 to 100.

tag String Indicates the tag name.

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

16

Page 20: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Return Valuel Normal

200l Abnormal

ReturnValue

Description

400 l The request cannot be understood by the server due to malformedsyntax. The client should not repeat the request withoutmodifications.

l The request parameter is incorrect.

401 The request requires user authentication.

403 No operation permission.

404 The server has not found anything matching the Request-URI.

500 The server encountered an unexpected condition which prevented it fromfulfilling the request.

2.2 Recapture Detection

FunctionAs a statistical method in the retailing industry, barcodes are used to calculate retailers' salesvolumes as the evidence of sales incentives. This API can be used to recognize whether abarcode image is the original one or the one that is recaptured or printed for recapturing byusing the deep neural network algorithm. It enables you to detect the invalid barcode imagesand makes the statistics more precise and valid.

URIURI format

POST /v1.0/image/recapture-detect

Requestl Sample request (Method 1: Use a Base64-encoded image.)

POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/image/recapture-detectRequest Header: Content-Type:application/jsonX-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...

Request Body:{ "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

17

Page 21: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj...", "url": "", "threshold":0.99, "scene":["recapture"]}

l Sample request (Method 2: Use the URL redirecting to the image file.)POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/image/recapture-detectRequest Header: Content-Type:application/jsonX-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...

Request Body:{ "image":"", "url":"https://BucketName.obs.myhwclouds.com/ObjectName", "threshold":0.99, "scene":["recapture"]}

l Parameter description

Parameter Mandatory Type Description

image Configureeither thisparameter orurl.

String Indicates the Base64 character stringconverted from the image. The sizecannot exceed 10 MB. The imageresolution of the narrow sides mustbe greater than 15 pixels, and that ofthe wide sides cannot exceed 4096pixels. The supported image formatsinclude JPG, PNG, and BMP.

url Configureeither thisparameter orimage.

String Indicates the URL of the image file.Currently, URLs for temporarilyauthorized access and anonymouslyand publicly authorized access toimage files stored on OBS aresupported.

threshold No Float Indicates the threshold used toidentify whether an image is real orfake. The default value is 0.95. Thevalue ranges from 0 to 1. If youinput a value beyond the valuerange, the default value prevails.

scene No List Indicates the detection scenario.Currently, only the recapturescenario is supported. Thisparameter can be left empty. If it isleft empty, the detection results of allscenarios are returned.

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

18

Page 22: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Responsel Sample response

{ "result":{ { "suggestion": "false", "category": "recapture", "score":"0.995", "detail": [ { "label":"recapture", "confidence":"0.995" } ] } }}

l Failed sample response{ "error_code": "AIS.0105", "error_msg": "Recognize Failed"}

l Parameter description

Parameter Type Description

result JSON Indicates the content of the image tag when the API issuccessfully called.This parameter is not included when the API fails tobe called.

suggestion String Indicates the conclusion. Possible values are asfollows:l true: indicates that the image is valid.l false: indicates that image is a fake one.l uncertainty: indicates that whether the image is

valid or fake is uncertain.

category String Indicates the tag (if suggestion is true, the value willbe a null string. Otherwise, the value will not be anull string).recapture: indicates that the image is a recapturedone.

score Float Indicates the overall confidence score. The valueranges from 0 to 1.0.

detail List Indicates the recognition result details.

label String Indicates the tag value. Possible values are as follows:l original: indicates that the image is the original

one.l recapture: indicates that the image is a recaptured

one.

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

19

Page 23: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Parameter Type Description

confidence Float Indicates the confidence score. The value ranges from0 to 1.0.

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Return Valuel Normal

200l Abnormal

ReturnValue

Description

400 l The request cannot be understood by the server due to malformedsyntax. The client should not repeat the request withoutmodifications.

l The request parameter is incorrect.

401 The request requires user authentication.

403 No operation permission.

404 The server has not found anything matching the Request-URI.

500 The server encountered an unexpected condition which prevented it fromfulfilling the request.

2.3 Dark Enhance

FunctionThis API can be used in scenarios where human eyes or machines cannot distinguish objectsin the dark when photographing images. It enhances dark areas, so that objects in the darkareas are visible, highlighting the effective visual information in the images. After you uploadthe image to be processed, Dark Enhance returns the enhanced image to you.

URIURI format

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

20

Page 24: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

POST /v1.0/vision/dark-enhance

Requestl Sample request (Method 1: Use a Base64-encoded image.)

POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/vision/dark-enhance Request Header: Content-Type:application/jsonX-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body:{ "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj...", "brightness":0.9}

l Sample request (Method 2: Use an image file.)POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/vision/dark-enhance Request Header: X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body(form-data): file: File (image file)brightness:0.9

l Parameter description

Parameter Mandatory Type Description

image Configureeither thisparameter orfile.

String Indicates the Base64 characterstring converted from the image.The size cannot exceed 10 MB.The supported image formatsinclude JPG, PNG, and BMP.

file Configureeither thisparameter orimage.

File Indicates the image file.

brightness No Float Indicates the brightness value.The default value is 0.9. Thevalue ranges from 0 to 1.

Response

Method 1: Use a Base64-encoded image.

l Sample response{ "result":"/9j/4AAQSkZJRgABAgEASABIAAD/

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

21

Page 25: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj..."}

l Failed sample response{ "error_code": "AIS.0105", "error_msg": "Recognize Failed"}

l Parameter description

Parameter Type Description

result String Indicates the Base64 character string converted fromthe image when the API is successfully called.This parameter is not included when the API fails tobe called.

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Method 2: Use an image file.

l Sample responseWhen the API is successfully called, the byte stream of the image file is returned.

l Failed sample response{ "error_code": "AIS.0105", "error_msg": "Recognize Failed"}

l Parameter description

Parameter Type Description

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

22

Page 26: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Return Valuel Normal

200l Abnormal

ReturnValue

Description

400 l The request cannot be understood by the server due to malformedsyntax. The client should not repeat the request withoutmodifications.

l The request parameter is incorrect.

401 The request requires user authentication.

403 No operation permission.

404 The server has not found anything matching the Request-URI.

500 The server encountered an unexpected condition which prevented it fromfulfilling the request.

2.4 Defog

FunctionWhen a camera takes photos in smoggy weather, the image quality will be poor because theshooting scene is unclear. This API can be used to remove both uniform and non-uniformsmog from images using the image defog algorithm. After you upload the image to beprocessed, Defog returns the processed image to you.

URIURI format

POST /v1.0/vision/defog

Requestl Sample request (Method 1: Use a Base64-encoded image.)

POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/vision/defog Request Header: Content-Type:application/jsonX-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body:{ "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEe

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

23

Page 27: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

ARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj...", "gamma":1.5, "natural_look":true}

l Sample request (Method 2: Use an image file.)POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/vision/defog Request Header: X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body(form-data):file: File (image file)gamma:1.5natural_look:true

l Parameter description

Parameter Mandatory Type Description

image Configureeither thisparameter orfile.

String Indicates the Base64 characterstring converted from the image.The size cannot exceed 10 MB.The supported image formatsinclude JPG, PNG, and BMP.

file Configureeither thisparameter orimage.

File Indicates the image file.

gamma No Float Indicates the gamma correctionvalue. The default value is 1.5.The value ranges from 0.1 to 10.

natural_look No Boolean Indicates whether to keep thenormal look. The default value istrue. If the parameter is set tofalse, the image is defogged, butthe visual effect may beunnatural.

ResponseMethod 1: Use a Base64-encoded image.

l Sample response{ "result":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj..."}

l Failed sample response{ "error_code": "AIS.0105",

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

24

Page 28: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

"error_msg": "Recognize Failed"}

l Parameter description

Parameter Type Description

result String Indicates the Base64 character string converted fromthe image when the API is successfully called.This parameter is not included when the API fails tobe called.

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Method 2: Use an image file.

l Sample response

When the API is successfully called, the byte stream of the image file is returned.

l Failed sample response{ "error_code": "AIS.0105", "error_msg": "Recognize Failed"}

l Parameter description

Parameter Type Description

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Return Valuel Normal

200

l Abnormal

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

25

Page 29: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

ReturnValue

Description

400 l The request cannot be understood by the server due to malformedsyntax. The client should not repeat the request withoutmodifications.

l The request parameter is incorrect.

401 The request requires user authentication.

403 No operation permission.

404 The server has not found anything matching the Request-URI.

500 The server encountered an unexpected condition which prevented it fromfulfilling the request.

2.5 Super Resolution

Function

This API can be used to compensate insufficient or lost image information due to excessivelyinsufficient pixels or compression. It uses deep learning algorithms to add missinginformation to images to achieve better visual effect. After you upload the image to beprocessed, Super Resolution returns the processed image to you.

URI

URI format

POST /v1.0/vision/super-resolution

Requestl Sample request (Method 1: Use a Base64-encoded image.)

POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/vision/super-resolution Request Header: Content-Type:application/jsonX-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body:{ "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj...", "scale":3, "model":"ESPCN"}

l Sample request (Method 2: Use an image file.)POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/vision/super-resolution

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

26

Page 30: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Request Header: X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body(form-data):file: File (image file)scale:3model:ESPCN

l Parameter description

Parameter Mandatory Type Description

image Configureeither thisparameter orfile.

String Indicates the Base64 characterstring converted from the image.The size cannot exceed 10 MB.The supported image formatsinclude JPG, PNG, and BMP.

file Configureeither thisparameter orimage.

File Indicates the image file.

scale No Integer Indicates the magnificationfactor. The default value is 3. Thevalue can be 3 or 4.

model No String Indicates the algorithm model.The default value is ESPCN.Possible values are as follows:ESPCN: Efficient Sub-PixelConvolutional Neural NetworkSRCNN: Super-ResolutionConvolutional Neural Network

Response

Method 1: Use a Base64-encoded image.

l Sample response{ "result":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj..."}

l Failed sample response{ "error_code": "AIS.0105", "error_msg": "Recognize Failed"}

l Parameter description

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

27

Page 31: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Parameter Type Description

result String Indicates the Base64 character string converted fromthe image when the API is successfully called.This parameter is not included when the API fails tobe called.

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Method 2: Use an image file.

l Sample responseWhen the API is successfully called, the byte stream of the image file is returned.

l Failed sample response{ "error_code": "AIS.0105", "error_msg": "Recognize Failed"}

l Parameter description

Parameter Type Description

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Return Valuel Normal

200l Abnormal

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

28

Page 32: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

ReturnValue

Description

400 l The request cannot be understood by the server due to malformedsyntax. The client should not repeat the request withoutmodifications.

l The request parameter is incorrect.

401 The request requires user authentication.

403 No operation permission.

404 The server has not found anything matching the Request-URI.

500 The server encountered an unexpected condition which prevented it fromfulfilling the request.

Image RecognitionAPI Reference 2 Image Recognition APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

29

Page 33: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

3 Service Management APIs

Service management APIs do not provide the actual service processing capabilities. They aremainly used for service API provisioning and usage query. As a supplement to servicemanagement, you can determine whether to access and invoke these APIs based on the actualapplication scenario.

3.1 Enabling Image Recognition

FunctionThis API is used to enable Image Recognition. You can make API calls or query servicecalling times only after you enable Image Recognition.

URIURI format

POST /v1.0/ais/subscribe

Requestl Sample request

POST https://ais.cn-north-1.myhuaweicloud.com/v1.0/ais/subscribe

Request Header:Content-Type: application/jsonX-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...

Request Body(x-www-form-urlencoded): service_type:image_taggingcategory:image_recognition

l Parameter description

Image RecognitionAPI Reference 3 Service Management APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

30

Page 34: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Parameter Mandatory

Type Description

service_type Configureeither thisparameterorcategory.

String Indicates the service name. Possiblevalues are as follows:image_tagging: Image Taggingimage_recapture_detect: RecaptureDetectiondark_enhance: Dark Enhancedefog: Defogsuper_resolution: Super ResolutionNOTE

If the value of this parameter is specified,the value of the category parameter canbe ignored, indicating that a specific sub-service is enabled.

category Configureeither thisparameterorservice_type.

String Indicates the service category.Possible values are as follows:l image_recognition: indicates

Image Recognition, includingImage Tagging and RecaptureDetection.

l vision: indicates Deblur, includingDark Enhance, Defog, and SuperResolution.

NOTEIf the value of service_type is specified,the value of this parameter can beignored. If service_type is notconfigured, the value of this parametertakes effect, indicating that all sub-services are enabled.

Responsel Sample response

{ "result": "success"}

l Failed sample response{ "error_code": "AIS.0005", "error_msg": "The service does not exist."}

l Parameter description

Image RecognitionAPI Reference 3 Service Management APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

31

Page 35: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Parameter Type Description

result String Indicates the calling result when the API issuccessfully called.This parameter is not included when the API fails tobe called.

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Return Valuel Normal

200l Abnormal

ReturnValue

Description

400 l The request cannot be understood by the server due to malformedsyntax. The client should not repeat the request withoutmodifications.

l The request parameter is incorrect.

401 The request requires user authentication.

403 No operation permission.

404 The server has not found anything matching the Request-URI.

500 The server encountered an unexpected condition which prevented it fromfulfilling the request.

3.2 Querying the Service Enabling Status

Function

This API is used to query the service enabling status.

URI

URI format

Image RecognitionAPI Reference 3 Service Management APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

32

Page 36: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

GET /v1.0/ais/subscribe

Requestl Sample request

GET https://ais.cn-north-1.myhuaweicloud.com/v1.0/ais/subscribe?service_type=image_tagging Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...

l Parameter description

Parameter Mandatory

Type Description

service_type Yes String Indicates the service name. Possiblevalues are as follows:image_tagging: Image Taggingimage_recapture_detect: RecaptureDetectiondark_enhance: Dark Enhancedefog: Defogsuper_resolution: Super Resolution

Responsel Sample response

{ "result": true}

l Failed sample response{ "error_code": "AIS.0005", "error_msg": "The service does not exist."}

l Parameter description

Parameter Type Description

result Boolean Indicates the calling result when the API issuccessfully called.This parameter is not included when the API fails tobe called.

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

Image RecognitionAPI Reference 3 Service Management APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

33

Page 37: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Parameter Type Description

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Return Valuel Normal

200l Abnormal

ReturnValue

Description

400 l The request cannot be understood by the server due to malformedsyntax. The client should not repeat the request withoutmodifications.

l The request parameter is incorrect.

401 The request requires user authentication.

403 No operation permission.

404 The server has not found anything matching the Request-URI.

500 The server encountered an unexpected condition which prevented it fromfulfilling the request.

3.3 Querying Service Calling Times

FunctionThis API is used to query service calling times.

URIURI format

GET /v1.0/ais/call_times

Requestl Sample request

GET https://ais.cn-north-1.myhuaweicloud.com/v1.0/ais/call_times?service_type=image_tagging Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...

Image RecognitionAPI Reference 3 Service Management APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

34

Page 38: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

l Parameter description

Parameter Mandatory

Type Description

service_type No String Indicates the service name. Possiblevalues are as follows:image_tagging: Image Taggingimage_recapture_detect: RecaptureDetectiondark_enhance: Dark Enhancedefog: Defogsuper_resolution: Super ResolutionNOTE

If the value of service_type is notspecified, the number of times that allservices are invoked is returned.

Responsel Sample response

{ "result": { "sub_time": "2017-08-30 09:22:51", "times": "1", "service_type": "image_tagging" } }

l Failed sample response{ "error_code": "AIS.0005", "error_msg": "The service does not exist."}

l Parameter description

Parameter Type Description

result JSON Indicates the calling result when the API issuccessfully called.This parameter is not included when the API fails tobe called.

sub_time String Indicates the time when the service is enabled.

times String Indicates the service calling times.

service_type String Indicates the service name. For details, seeParameter description.

error_code String Indicates the error code when the API fails to becalled. For details, see A.3 Error Code.This parameter is not included when the API issuccessfully called.

Image RecognitionAPI Reference 3 Service Management APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

35

Page 39: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Parameter Type Description

error_msg String Indicates the error message when the API fails to becalled.This parameter is not included when the API issuccessfully called.

Return Valuel Normal

200l Abnormal

ReturnValue

Description

400 l The request cannot be understood by the server due to malformedsyntax. The client should not repeat the request withoutmodifications.

l The request parameter is incorrect.

401 The request requires user authentication.

403 No operation permission.

404 The server has not found anything matching the Request-URI.

500 The server encountered an unexpected condition which prevented it fromfulfilling the request.

Image RecognitionAPI Reference 3 Service Management APIs

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

36

Page 40: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

A Appendix

A.1 Common Message HeadersThis section describes the common request and response message headers.

Common Request Headers

Table A-1 Common request headers

Parameter Description Mandatory Example Value

X-Sdk-Date Indicates the timewhen the request issent. The time is inYYYYMMDD'T'HHMMSS'Z' format.The value is thecurrent GMT time ofthe system.

NoThis parameteris mandatoryfor AK/SKauthentication.

20150907T101459Z

Authorization Indicates thesignatureauthenticationinformation.The value can beobtained from therequest signing result.

NoThis parameteris mandatoryfor AK/SKauthentication.

SDK-HMAC-SHA256Credential=ZIRRKMTWPTQFQI1WKNKB/20150907//ec2/sdk_request,SignedHeaders=content-type;host;x-sdk-date,Signature=55741b610f3c9fa3ae40b5a8021ebf7ebc2a28a603fc62d25cb3bfe6608e1994

Image RecognitionAPI Reference A Appendix

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

37

Page 41: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Parameter Description Mandatory Example Value

Host Indicates the serverdomain name and portnumber of theresource beingrequested. The valuecan be obtained fromthe URL of theservice API. Thevalue ishostname[:port]. Ifthe port number is notspecified, the defaultport is used. Thedefault port numberfor https is 443.

NoThis parameteris mandatoryfor AK/SKauthentication.

code.test.comorcode.test.com:443

Content-Type Indicates the MIMEtype of the requestbody.

Yes application/json

Content-Length Indicates the length ofthe request body. Theunit is byte.

This parameteris mandatoryfor POST andPUT requests,but must be leftblank for GETrequests.

3495

X-Project-Id Indicates the projectID. This parameter isused to obtain thetoken for eachproject.This parameter ismandatory for therequest from a DeC ormulti-project user.

No e9993fc787d94b6c886cbaa340f9c0f4

X-Auth-Token Indicates the usertoken.

NoThis parameteris mandatoryfor tokenauthentication.

-

NOTE

For details about other parameters in the header, see the HTTP protocol documentation.

Image RecognitionAPI Reference A Appendix

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

38

Page 42: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Common Response Headers

Table A-2 Common response headers

Parameter Description

Content-Length Indicates the length of the response body. The unit is byte.

Date Indicates the time when a request response is returned.

Content-Type Indicates the MIME type of the response body.

A.2 Status CodeStatusCode

Code Description

100 Continue The client continues sending the request.The server has received the initial part of therequest and the client should continue sending theremaining part.

101 Switching Protocols The requester has asked the server to switchprotocols and the server has agreed to do so. Thetarget protocol must be more advanced than thesource protocol.For example, the current HTTP protocol isswitched to a later version.

200 OK The server has successfully processed the request.

201 Created The request for creating a resource has beenfulfilled.

202 Accepted The request has been accepted for processing, butthe processing has not been completed.

203 Non-AuthoritativeInformation

The server successfully processed the request, butis returning information that may be from anothersource.

204 No Content The server has successfully processed the request,but has not returned any content.The status code is returned in response to an HTTPOPTIONS request.

205 Reset Content The server has fulfilled the request, but therequester is required to reset the content.

206 Partial Content The server has successfully processed a part of theGET request.

Image RecognitionAPI Reference A Appendix

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

39

Page 43: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

StatusCode

Code Description

300 Multiple Choices There are multiple options for the location of therequested resource. The response contains a list ofresource characteristics and addresses from whichthe user or user agent (such as a browser) canchoose the most appropriate one.

301 Moved Permanently The requested resource has been assigned a newpermanent URI, and the new URI is contained inthe response.

302 Found The requested resource resides temporarily under adifferent URI.

303 See Other Retrieve a location.The response to the request can be found under adifferent URI and should be retrieved using a GETor POST method.

304 Not Modified The requested resource has not been modified.When the server returns this status code, it does notreturn any resources.

305 Use Proxy The requested resource must be accessed through aproxy.

306 Unused The HTTP status code is no longer used.

400 Bad Request The request is invalid.The client should not repeat the request withoutmodifications.

401 Unauthorized The status code is returned after the client providesthe authentication information, indicating that theauthentication information is incorrect or invalid.

402 Payment Required This status code is reserved for future use.

403 Forbidden The server understood the request, but is refusingto fulfill it.The client should not repeat the request withoutmodifications.

404 Not Found The requested resource cannot be found.The client should not repeat the request withoutmodifications.

405 Method Not Allowed The method specified in the request is notsupported for the requested resource.The client should not repeat the request withoutmodifications.

Image RecognitionAPI Reference A Appendix

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

40

Page 44: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

StatusCode

Code Description

406 Not Acceptable The server cannot fulfill the request according tothe content characteristics of the request.

407 Proxy AuthenticationRequired

This status code is similar to 401, but indicates thatthe client must first authenticate itself with theproxy.

408 Request Timeout The server times out when waiting for the request.The client may repeat the request withoutmodifications at any later time.

409 Conflict The request could not be completed due to aconflict with the current state of the resource.This status code indicates that the resource that theclient attempts to create already exits, or therequest fails to be processed because of the updateof the conflict request.

410 Gone The requested resource is no longer available.The status code indicates that the requestedresource has been deleted permanently.

411 Length Required The server refuses to process the request without adefined Content-Length.

412 Precondition Failed The server does not meet one of the preconditionsthat the requester puts on the request.

413 Request Entity TooLarge

The request is larger than that a server is able toprocess. The server may close the connection toprevent the client from continuing the request. Ifthe server cannot process the request temporarily,the response will contain a Retry-After headerfield.

414 Request URI Too Long The URI provided was too long for the server toprocess.

415 Unsupported MediaType

The server is unable to process the media format inthe request.

416 Requested Range NotSatisfiable

The requested range is invalid.

417 Expectation Failed The server fails to meet the requirements of theExpect request-header field.

422 Unprocessable Entity The request is well-formed but is unable to beprocessed due to semantic errors.

Image RecognitionAPI Reference A Appendix

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

41

Page 45: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

StatusCode

Code Description

429 Too Many Requests The client sends excessive requests to the serverwithin a given time (exceeding the limit on theaccess frequency of the client), or the serverreceives excessive requests within a given time(beyond its processing capability). In this case, theclient should repeat requests after the timespecified in the Retry-After header of the responseexpires.

500 Internal Server Error The server is able to receive but unable tounderstand the request.

501 Not Implemented The server does not support the function requiredto fulfill the request.

502 Bad Gateway The server was acting as a gateway or proxy andreceived an invalid response from the upstreamserver.

503 Service Unavailable The requested service is invalid.The client should not repeat the request withoutmodifications.

504 Gateway Timeout The request cannot be fulfilled within a given time.This status code is returned to the client only whenthe Timeout parameter is specified in the request.

505 HTTP Version NotSupported

The server does not support the HTTP protocolversion used in the request.

A.3 Error Code

FunctionIf the returned status code of HUAWEI CLOUD is 400, the customized error message willalso be returned. This section describes the meaning of each error code.

Response Body FormatSTATUS CODE 400{ "error_code": "AIS.0005", "error_msg": "The service does not exist."}

Image RecognitionAPI Reference A Appendix

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

42

Page 46: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Error CodeModule Error Code Description

Common AIS.0002 The authentication token is abnormal.

AIS.0003 Failed to complete the request because of aninternal service error.

AIS.0004 The request is unauthorized.

AIS.0005 The service does not exist.

AIS.0007 The service has not been enabled yet.

AIS.0010 The header is missing or left empty.

AIS.0011 The request parameter is missing or left empty.

AIS.0012 The request parameter is not supported.

AIS.0013 The request method is not allowed.

AIS.0014 The JSON format of the input data is incorrect.

AIS.0015 Base64 decoding of the input data is incorrect.

AIS.0020 The size of the request body exceeds the upperlimit.

AIS.0021 The requested file type is not supported.

AIS.0022 The URL is invalid.

AIS.0023 The file stored on OBS is oversized.

AIS.0024 Failed to obtain the file from OBS. The signaturehas expired or fails to pass the authentication.

AIS.0025 The file stored on OBS is empty.

ImageRecognition

AIS.0201 An exception occurred during the process ofobtaining the input image.

AIS.0202 The image format is not supported.

AIS.0203 The input parameter does not meet therequirements.

AIS.0204 The color depth is not supported.

AIS.0205 The resolution of the image exceeds the upper limit.

AIS.0206 Algorithm calculation failed.

AIS.0501 The input parameter is invalid.

AIS.0502 The image format is not supported.

AIS.0503 The image is damaged.

Image RecognitionAPI Reference A Appendix

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

43

Page 47: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

Module Error Code Description

AIS.0504 The image size does not meet requirements.

AIS.0505 Failed to run the algorithm.

AIS.0506 An internal error occurred.

Image RecognitionAPI Reference A Appendix

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

44

Page 48: API Reference · Image Recognition API Reference Issue 04 Date 2018-07-16 HUAWEI TECHNOLOGIES CO., LTD

B Change History

Release Date What's New

2018-07-16 This is the fourth official release.l Modified the following content:

Modified the procedure for applying for a service in Applyingfor a Service.

2018-07-02 This is the third official release.l Added the following content:

– Added Dark Enhance.– Added Defog.– Added Super Resolution.

2018-01-18 This is the second official release.l Modified the following content:

Changed the domain name myhwclouds to myhuaweicloud.

2017-12-22 This is the first official release.

Image RecognitionAPI Reference B Change History

Issue 04 (2018-07-16) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.

45