All Products
Search
Document Center

:Smart element recognition

Last Updated:Sep 13, 2026

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.

  • 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

image.png

Main subject

  • Watermark: false

  • Text: false

  • Colored patch with text: false

Non-subject area

  • Watermark: false

  • Text: true

  • Colored patch with text: false

image.png

Main subject

  • Watermark: false

  • Text: false

  • Colored patch with text: false

Non-subject area

  • Watermark: true

  • Text: true

  • Colored patch with text: true

Supported elements

Value

Description

Definition

1

Watermark

Monochromatic and transparent text, badges, images, URLs, store names, and more.

2

Logo

A badge or trademark.

3

Text

Horizontally, vertically, or diagonally oriented Chinese or English text.

4

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/recognition

For 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

ImageUrl

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.

ObjectDetectElements

Number[]

Conditional

An array of enumeration values (1-4) for elements to detect on the main subject. You must specify at least one of ObjectDetectElements or NonObjectDetectElements.

NonObjectDetectElements

Number[]

Conditional

An array of enumeration values (1-4) for elements to detect on the non-subject area.

ReturnCharacter

Number

No

Specifies whether to return the OCR text result for the recognition area: 1 to return the result, or 0 (default) to not return the result.

ReturnBorderPixel

Number

No

Specifies whether to return the distance from the subject to the edge of the image: 1 returns the distance, and 0 does not (default). See Data.BorderPixel for the returned value.

ReturnProductProp

Number

No

Whether to return the subject area proportion: 1 / 0 (default).

ReturnProductNum

Number

No

Whether to return the number of entities: 1 / 0 (default).

ReturnCharacterProp

Number

No

Specifies whether to return the text area proportion: 1 / 0 (default). Prerequisites: ReturnCharacter=1 and at least one of ObjectDetectElements or NonObjectDetectElements contains 3 (text).

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

Code

String

The business status code. Success indicates a successful operation.

Message

String

The error message. A successful call returns "Success".

Success

Boolean

Indicates whether the API call was successful.

RequestId

String

The unique request ID.

Data

Object

The object containing the recognition results.

Data.ObjWatermark

Boolean

Indicates whether a watermark is present on the main subject.

Data.ObjLogo

Boolean

Indicates whether a logo is present on the main subject.

Data.ObjCharacter

Boolean

Indicates whether text is present on the main subject.

Data.ObjNpx

Boolean

Indicates whether a colored patch with text is present on the main subject. For the definition, see the Supported elements table.

Data.NoobjWatermark

Boolean

Indicates whether a watermark is present on the non-subject area.

Data.NoobjLogo

Boolean

Indicates whether a logo is present on the non-subject area.

Data.NoobjCharacter

Boolean

Indicates whether text is present on the non-subject area.

Data.NoobjNpx

Boolean

Indicates whether a colored patch with text is present on the non-subject area.

Data.RecText

String[]

An array of text recognized by OCR. Returned when ReturnCharacter=1.

Data.BorderPixel

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 "top,bottom,left,right,width,height". This value is returned when ReturnBorderPixel=1.

Data.PdProp

String

The subject area proportion, which is a percentage string such as "53.77%". This parameter is returned when ReturnProductProp=1.

Data.PdNum

Number

Number of main products. Returned when ReturnProductNum=1.

Data.TextProp

String

The proportion of the text area is a percentage string such as "7.56%" and takes effect only when the ReturnCharacterProp request parameter is specified.

Data.UsageMap

Object

The usage object.

Data.UsageMap.ProcessedImageCount

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 returned NoobjWatermark or NoobjLogo.

  • Combination of OCR and text matching: If you are only interested in identifying brand names rather than any text, set ReturnCharacter=1, retrieve the RecText value, and then perform keyword matching on the client side.

  • Subject count and area: If PdNum > 1 or PdProp is 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

InvalidParameter

ImageUrl is inaccessible, the image format or resolution is out of range, or ObjectDetectElements and NonObjectDetectElements are both empty.

InputContentBlocked

The input image triggers content moderation.

DownstreamUnavailable

Image download fails, or a downstream vision model is temporarily unavailable. Retry with exponential backoff.

FreeQuotaExhausted

The free quota has been used up. You need to purchase a resource plan or disable the "stop when quota is exhausted" setting.

InternalError

Internal server error. Please save the RequestId and contact technical support.

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

How should I use the Smart Element Recognition API?

This API is typically used with Smart Erase. First, automatically screen for images that contain target elements, then perform batch removal. This API also includes an OCR feature, which helps you filter for images that contain text and recognize the text content.

What is a "colored patch with text"?

It refers to a flyer-style ad or a similar colored block containing text, such as a label.

Next steps

  • Smart Erase – The second step in the "detect then erase" workflow.

  • Smart Matting - Uses BorderPixel or PdProp to evaluate the feasibility of matting.