Designed specifically for e-commerce images, Smart Element Recognition detects four types of elements on both the main subject and background of an image: text, a logo, a watermark, and a colored patch with text (flyer-style ad). The API returns a boolean (yes/no) result and can optionally provide quantitative metrics like the original text from Optical Character Recognition (OCR), the subject area proportion, and the text area proportion. Use this feature as a preliminary step for operations like Smart Erase or Smart Matting to improve the efficiency and accuracy of batch filtering. This is a synchronous call.
Use cases
Automated image screening and optimization: Automatically identify images containing specific elements like a watermark or logo, then use Smart Erase for batch processing. This improves image quality and shortens the time-to-market for your products.
Workflow automation and efficiency: Automate your image processing pipeline by identifying and flagging elements that require optimization, reducing the need for manual intervention.
Features
Element definitions
For definitions and visual examples of the main subject, background, and the four element types, see the "Features" and "Comparison" sections of the Smart Erase documentation. The element enumeration values used in this API are consistent with those in Smart Erase.
Main subject: The core product area within an image.
Background: Everything in the image except the main subject.
Text: Horizontally, vertically, or diagonally oriented Chinese or English text.
Logo: A badge or trademark.
Watermark: Monochromatic and transparent text, badges, images, URLs, store names, and more.
Colored patch with text: A colored patch that contains text (also known as a flyer-style ad).
Key capabilities
Element recognition: Detects the presence of text, a logo, a watermark, or a colored patch with text on the main subject and background of an image.
Workflow integration: Use with Smart Erase. First, identify the elements to remove, then erase them to ensure accurate and efficient processing.
Technical advantages
Synchronous batch processing: As a synchronous API, it can process a large number of images while maintaining fast response times, making it suitable for businesses of all sizes.
Flexibility: You can specify which element types to detect and where to detect them (on the main subject or non-subject area), allowing for customized recognition tasks.
Comparison
Original image | Recognition result |
| Main subject
Non-subject area
|
| Main subject
Non-subject area
|
Supported elements
Value | Description | Definition |
| Watermark | Monochromatic and transparent text, badges, images, URLs, store names, and more. |
| Logo | A badge or trademark. |
| Text | Horizontally, vertically, or diagonally oriented Chinese or English text. |
| Colored patch with text | A colored patch with text, also known as a flyer-style ad. It can appear on both the main subject and the non-subject area, and is commonly found on promotional stickers or origin labels. |
Consistent with Smart Erase, the main subject refers to the core product area, and the non-subject area refers to the background. You can specify detection parameters for these two areas independently.
API
POST /rest/ai/image/recognitionFor complete request signing instructions, multi-language SDK examples (Java, Python, Go, and more), and an online debugging tool, see the Alibaba Cloud OpenAPI Developer Portal: Smart Element Recognition API (OpenAPI Portal).
Request parameters
Parameter | Type | Required | Description |
| String | Yes | The URL of the image. Requirements: JPG, JPEG, PNG, BMP, or WEBP format; resolution between 256×256 and 3000×3000 pixels; file size ≤ 10 MB. |
| Number[] | Conditional | An array of enumeration values (1-4) for elements to detect on the main subject. You must specify at least one of |
| Number[] | Conditional | An array of enumeration values (1-4) for elements to detect on the non-subject area. |
| Number | No | Specifies whether to return the OCR text result for the recognition area: |
| Number | No | Specifies whether to return the distance from the subject to the edge of the image: |
| Number | No | Whether to return the subject area proportion: |
| Number | No | Whether to return the number of entities: |
| Number | No | Specifies whether to return the text area proportion: |
Response fields
All boolean fields follow the naming convention of Obj prefix for main subject / Noobj prefix for non-subject area + element name. Return values for elements not specified in the request are insignificant and typically default to false.
Parameter | Type | Description |
| String | The business status code. |
| String | The error message. A successful call returns |
| Boolean | Indicates whether the API call was successful. |
| String | The unique request ID. |
| Object | The object containing the recognition results. |
| Boolean | Indicates whether a watermark is present on the main subject. |
| Boolean | Indicates whether a logo is present on the main subject. |
| Boolean | Indicates whether text is present on the main subject. |
| Boolean | Indicates whether a colored patch with text is present on the main subject. For the definition, see the Supported elements table. |
| Boolean | Indicates whether a watermark is present on the non-subject area. |
| Boolean | Indicates whether a logo is present on the non-subject area. |
| Boolean | Indicates whether text is present on the non-subject area. |
| Boolean | Indicates whether a colored patch with text is present on the non-subject area. |
| String[] | An array of text recognized by OCR. Returned when |
| String | The distances from the subject to the four borders of the image and the width and height of the original image, in the format |
| String | The subject area proportion, which is a percentage string such as |
| Number | Number of main products. Returned when |
| String | The proportion of the text area is a percentage string such as |
| Object | The usage object. |
| Number | The number of images processed, used for billing reconciliation. |
Example
Request example
{
"ImageUrl": "https://cbu01.alicdn.com/img/ibank/example.jpg",
"ObjectDetectElements": [1, 2, 3, 4],
"NonObjectDetectElements": [1, 2, 3, 4],
"ReturnCharacter": 1,
"ReturnBorderPixel": 1,
"ReturnProductProp": 1,
"ReturnProductNum": 1,
"ReturnCharacterProp": 1
}Response example
{
"Code": "success",
"Message": "Success",
"Success": true,
"RequestId": "2157065A-D6C8-1F3E-A4D0-B1234567890",
"Data": {
"ObjWatermark": false,
"ObjLogo": false,
"ObjCharacter": false,
"ObjNpx": false,
"NoobjWatermark": true,
"NoobjLogo": false,
"NoobjCharacter": false,
"NoobjNpx": false,
"RecText": [],
"BorderPixel": "154,26,36,59,790,895",
"PdProp": "53.77%",
"PdNum": 1,
"TextProp": "0.0%",
"UsageMap": { "ProcessedImageCount": 1 }
}
}Recommendations
Detect non-subject elements only: A common use case for e-commerce main images is to remove background watermarks or logos without affecting the main subject. You can set
NonObjectDetectElements=[1,2]and then decide whether to use Smart Erase based on the returnedNoobjWatermarkorNoobjLogo.Combination of OCR and text matching: If you are only interested in identifying brand names rather than any text, set
ReturnCharacter=1, retrieve theRecTextvalue, and then perform keyword matching on the client side.Subject count and area: If
PdNum > 1orPdPropis abnormally small (such as < 10%), it usually means that the original image is highly complex and the subsequent matting/cropping results may be unstable. A manual review is recommended.Handle batch processing: The API has a default limit of 5 QPS. For processing multiple images, we recommend implementing concurrency control on the client side (for example, using 4 worker threads) instead of sending the entire batch in a single synchronous request.
Error codes
Error code | Trigger |
|
|
| The input image triggers content moderation. |
| Image download fails, or a downstream vision model is temporarily unavailable. Retry with exponential backoff. |
| The free quota has been used up. You need to purchase a resource plan or disable the "stop when quota is exhausted" setting. |
| Internal server error. Please save the |
For a complete list of error codes, see Error codes.
Limitations
Call mode: Synchronous. The default QPS is 5, and the timeout for a single request is 30 seconds.
Input image: JPG, JPEG, PNG, BMP, or WEBP format; resolution between 256×256 and 3000×3000 pixels; file size ≤ 10 MB.
Billing: $0.0042/image, billed based on the
ProcessedImageCount. For more information, see Billing for Asset Optimization.
FAQ
Next steps
Smart Erase – The second step in the "detect then erase" workflow.
Smart Matting - Uses
BorderPixelorPdPropto evaluate the feasibility of matting.

