Distortion Correction
Function
This API only identifies whether the original image of an enterprise form is distorted, and corrects the distortion.
Prerequisites
By default, the maximum number of concurrent API calls is 3. To increase concurrency, contact Huawei technical support.
URI
URI format
POST /v1.0/moderation/image/distortion-correct
Request Message
Table 1 describes the request parameters.
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
image |
Configure either this parameter or url. |
String |
Indicates the Base64 character string converted from the image. The size cannot exceed 10 MB. The supported image formats include JPG, PNG, and BMP. |
url |
Configure either this parameter or image. |
String |
Indicates the URL of an image. The options are as follows:
NOTE:
The API response time depends on the image download time. If the image download takes a long time, the API call will fail. Ensure that the storage service where the image to be detected resides is stable and reliable. You are advised to use HUAWEI CLOUD OBS. |
correction |
No |
Boolean |
Indicates whether to perform image distortion correction.
|
Response Message
Table 2 describes the response parameters.
Parameter |
Type |
Description |
---|---|---|
result |
Object |
Indicates the calling result when the API is successfully called. This parameter is not included when the API fails to be called. |
distortion |
Boolean |
Indicates the identification result.
|
data |
String |
Indicates the image after distortion correction, which is a Base64 character string converted from the image. If the image is not distorted, no distortion correction is required, or the output parameter indicates that no distortion correction is required. In this case, the return value is a null string. |
error_code |
String |
Indicates the error code when the API fails to be called. For details, see Error Codes. This parameter is not included when the API is successfully called. |
error_msg |
String |
Indicates the error message when the API fails to be called. This parameter is not included when the API is successfully called. |
Examples
- Example request (Method 1: Use a Base64-encoded image.)
POST https://moderation.ap-southeast-1.myhuaweicloud.com/v1.0/moderation/image/distortion-correct Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj...", "url": "", "correction":true }
- Example request (Method 2: Use the URL redirecting to the image file.)
POST https://moderation.ap-southeast-1.myhuaweicloud.com/v1.0/moderation/image/distortion-correct Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "image":"", "url":"https://BucketName.obs.myhuaweicloud.com/ObjectName", "correction":true }
- Example successful response
{ "result":{ "distortion": true, "data": "/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAA..." } }
- Example failed response
{ "error_code": "AIS.0005", "error_msg": "The service does not exist." }
Status Code
- Normal
- Abnormal
Return Value
Description
400
- The request cannot be understood by the server due to malformed syntax. The client should not repeat the request without modifications.
- 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 from fulfilling the request.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot