This topic describes the syntax of the SearchImageByPic operation and provides examples of this operation. You can call this operation to search for images by image on an Image Search instance.
Usage notes
You can call this operation to search for similar images on an Image Search instance based on an image.
To learn more about Image Search, submit your questions on the presale online consultation page or contact us in the DingTalk group (ID 35035130) for technical support.
QPS limits
You can view the default maximum number of queries per second (QPS) in the Image Search console. The upper limit is specified when you purchase an Image Search instance. You can set the upper limit to 1 QPS, 5 QPS, or 10 QPS.
SDK version
You must update Image Search SDK to version 3.1.1, which supports multi-subject identification and similarity scores. For more information, see SDK for Java.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | SearchImageByPic | The operation that you want to perform. Set the value to SearchImageByPic. |
InstanceName | String | Yes | demoinstance1 | The name of the Image Search instance. The name can be up to 20 characters in length. If an Image Search instance is purchased, you can log on to the Image Search console to view the instance. If no Image Search instance is purchased, you must purchase an instance. For more information, see Activate Image Search and Create an Image Search instance. Note The instance name is not the instance ID. |
PicContent | String | Yes | AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII= | The image.
Note
|
CategoryId | Integer | No | 88888888 | The ID of the product category. For more information, see Category references.
|
Crop | Boolean | No | true | Specifies whether to identify the subject in the image and search for images based on the identified subject. Default value: true. Valid values:
|
Region | String | No | 280,486,232,351 | The subject area of the image. Specify the subject area in the following format: Note
|
Num | Integer | No | 10 | The number of entries to return. Valid values: 1 to 100. Default value: 10. |
Start | Integer | No | 0 | The ordinal number of the first entry to return. Valid values: 0 to 499. Default value: 0. |
Filter | String | No | int_attr=1000 AND str_attr="value1" | The filter condition. int_attr supports the following operators: >, >=, <, <=, and =. str_attr supports the following operators: = and !=. You can use AND or OR to associate the conditions. Examples:
Note The value can be up to 4,096 characters in length. |
DistinctProductId | Boolean | No | false | Specifies whether to deduplicate data based on ProductId If this parameter is set to true, data is deduplicated based on ProductId. |
Response parameters
Parameter | Type | Example | Description |
Msg | String | success | The returned message. |
Head | Object | The summary of the search results. | |
DocsFound | Integer | 10 | The number of images returned. |
DocsReturn | Integer | 10000 | The number of images that match the search conditions on the Image Search instance. |
SearchTime | Integer | 95 | The search duration. Unit: milliseconds. |
RequestId | String | B3137727-7D6E-488C-BA21-0E034C38A879 | The request ID. |
Auctions | Array of Auction | The product descriptions returned. | |
ProductId | String | 2092061_1 | The product ID. |
PicName | String | 2092061_1.jpg | The name of the image. |
CategoryId | Integer | 8888888 | The category ID of the image. |
SortExprValues | String | 5.37633353624177e+24;0 | The scoring information of the image. Note
|
CustomContent | String | zidingyi | The user-defined content. |
Score | Float | 1 | The similarity score of the searched image. Valid values: 0 to 1. Note To use this parameter, you must update Image Search SDK to version 3.1.1. |
IntAttr | Integer | 2 | The attribute, which is an integer. |
IntAttr2 | Integer | 20 | The attribute, which is an integer. |
StrAttr2 | String | test | The attribute, which is a string. |
StrAttr | String | test | The attribute, which is a string. |
StrAttr3 | String | test | The attribute, which is a string. |
StrAttr4 | String | test | The attribute, which is a string. |
IntAttr3 | Integer | 2 | The attribute, which is an integer. |
IntAttr4 | Integer | 2 | The attribute, which is an integer. |
Code | Integer | 0 | The response code.
|
PicInfo | Object | The results of category prediction and subject identification. | |
Region | String | 280,486,232,351 | The result of subject identification. The value indicates the subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 indicate the upper-left pixel, and x2 and y2 indicate the lower-right pixel. If a subject area is specified in the request, the specified subject area prevails. |
CategoryId | Integer | 88888888 | The result of category prediction. If a category is specified in the request, the specified category prevails. |
MultiRegion | Array of reg | The identified subjects. Note To use this parameter, you must update Image Search SDK to version 3.1.1. | |
Region | String | 280,486,232,351 | The result of subject identification. The value indicates the subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 indicate the upper-left pixel, and x2 and y2 indicate the lower-right pixel. If a subject area is specified in the request, the specified subject area prevails. |
AllCategories | Array of Category | The supported categories. | |
Name | String | other | The name of the category. |
Id | Integer | 88888888 | The category ID. |
Success | Boolean | true | Indicates whether the request was successful. |
Examples
Sample requests
{
"InstanceName": "demoinstance",
"PicContent": "${Base64ImageContent}"
}
Sample success responses
JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"Auctions" : [ {
"CategoryId" : 0,
"PicName" : "demo",
"SortExprValues" : "7.33136443711219e+24;0",
"Score" : 1.0,
"ProductId" : "demo"
} ],
"Head" : {
"DocsReturn" : 1,
"DocsFound" : 1,
"SearchTime" : 155
},
"PicInfo" : {
"CategoryId" : 0,
"Region" : "111,697,113,774",
"AllCategories" : [ {
"Name" : "Tops",
"Id" : 0
}, {
"Name" : "Dress",
"Id" : 1
}, {
"Name" : "Bottoms",
"Id" : 2
}, {
"Name" : "Bag",
"Id" : 3
}, {
"Name" : "Shoes",
"Id" : 4
}, {
"Name" : "Accessories",
"Id" : 5
}, {
"Name" : "Snack",
"Id" : 6
}, {
"Name" : "Makeup",
"Id" : 7
}, {
"Name" : "Bottle",
"Id" : 8
}, {
"Name" : "Furniture",
"Id" : 9
}, {
"Name" : "Toy",
"Id" : 20
}, {
"Name" : "Underwear",
"Id" : 21
}, {
"Name" : "Digital device",
"Id" : 22
}, {
"Name" : "Other",
"Id" : 88888888
} ],
"MultiRegion" : [ {
"Region" : "604,1814,451,1358"
}, {
"Region" : "843,1615,687,1138"
} ]
},
"RequestId" : "D61D869E-E92A-447F-AD67-9234F999E516",
"Msg" : "success",
"Success" : true,
"Code" : 0
}
Error codes
HTTP status code | Error code | Error message | Description |
400 | BadRequest | The request has invalid parameters. | One or more parameters are invalid. |
400 | InvalidInstance | The specified instance name is invalid. | The instance name is invalid. |
400 | NoCaretSeperator | The body content is missing the ^ separator. | Specific symbols are missing in the request body. |
400 | EmptyMeta | The body content has an empty meta field. | The request body contains an empty parameter. |
400 | InvalidMetaItem | The meta field is invalid. | A meta parameter is invalid. |
400 | NoPicList | The body content is missing the pic_list parameter. | The pic_list parameter is not specified. |
400 | InvalidPicList | The specified pic_list parameter is invalid. | The pic_list parameter is invalid. |
400 | InvalidCategory | The specified category is invalid. | The category ID is invalid. |
400 | OverflowMaxResultNum | The specified number of total results exceeds the maximum of 500. | The specified total number of entries to return exceeds the upper limit, which is 500. |
400 | OverflowMaxReturnNum | The specified number of results for each request exceeds the maximum of 100. | The specified number of entries to return for a single request exceeds the upper limit, which is 100. |
400 | InvalidNumParameter | The specified parameter num is invalid. | The Num parameter is invalid. |
400 | InvalidIntAttr | The specified int_attr field is invalid. | The IntAttr parameter is invalid. |
400 | UnsupportedPicFormat | The specified image format is invalid. | The image format is invalid. |
400 | InvalidFilterClause | The specified filtering condition is invalid. | The filter condition is invalid. |
400 | InstanceOverQuota | The number of items exceeds the limit. | The number of images on the instance exceeds the upper limit. |
400 | IncorrectOrientation | The image contains incorrect rotation flags in the meta data. | The image contains unsupported rotation settings. |
400 | UnsupportedPicPixels | The specified pixels is not supported. | The specified image pixel value is not supported. |
400 | InvalidStrAttr | The specified parameter StrAttr is not valid. | The StrAttr parameter is invalid. |
400 | InvalidIntAttr4 | The specified parameter IntAttr4 is not valid. | The IntAttr4 parameter is invalid. |
400 | InvalidIntAttr3 | The specified parameter IntAttr3 is not valid. | The IntAttr3 parameter is invalid. |
400 | InvalidIntAttr2 | The specified parameter IntAttr2 is not valid. | The IntAttr2 parameter is invalid. |
400 | InvalidIntAttr | The specified parameter IntAttr is not valid. | The IntAttr parameter is invalid. |
400 | InvalidStrAttr4 | The specified parameter StrAttr4 is not valid. | The StrAttr4 parameter is invalid. |
400 | InvalidStrAttr3 | The specified parameter StrAttr3 is not valid. | The StrAttr3 parameter is invalid. |
400 | InvalidStrAttr2 | The specified parameter StrAttr2 is not valid. | The StrAttr2 parameter is invalid. |
403 | NoPermission | You are not authorized to perform this operation. | You are not authorized to perform this operation |
403 | DeniedRequest | Your request was denied due to instance flow control. | Your request was denied due to throttling. |
500 | UnknownException | An internal server error occurred. | An unknown error has occurred. |
500 | NetworkException | A network error occurred. | A network error has occurred. |
500 | UnsupportedInstanceType | The instance type is not supported. | The instance type is not supported. |
500 | UnsupportedOperationType | The specified action is not supported. | The specified operation is not supported. |
500 | AccessEngineFailed | An error occurred while accessing the search engine. | An error has occurred in the search engine. |
500 | InternalOssError | An internal OAS error occurred. | An internal algorithm error has occurred. |
500 | InternalSwiftError | An internal SWIFT error occurred. | An internal message queue error has occurred. |
500 | InternalTableStoreError | An internal Table Store error occurred. | An internal storage error has occurred. |
500 | ConnectionDVException | Failed to obtain collection. | internalError |
500 | PictureError | [download] Img Download Failed. | Failed to download the image. Check the image and try again. |
For more error codes, see Service error codes.
Error codes
For a list of error codes, see Service error codes.