AddImage - 新增图片

更新时间:
复制 MD 格式

本文为您介绍AddImage接口的语法及示例,用于向图像搜索实例中添加图片信息。

接口说明

使用说明

本接口用于向图像搜索实例中添加图片信息。

QPS 限制

10W 图片容量的实例默认的并发量为 1,也就是每秒钟最多处理 1 个图片新增请求。 其他图片容量的实例默认的并发量为 5,也就是每秒钟最多处理 5 个图片新增请求。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

imagesearch:AddImage

create

*全部资源

*

无 无

请求参数

名称

类型

必填

描述

示例值

InstanceName

string

是

图搜实例名称。最多支持 20 个字符。 如果已经购买图搜实例可登录图像搜索管控台查看。 如果没有购买图搜实例可参考开通服务和创建实例。

说明

这里的实例名称并非实例 ID,使用时请区分。

demoinstance1

ProductId

string

是

商品 ID,最多支持 256 个字符。

说明

一个商品可以有多张图片。

2092061_1

PicName

string

是

图片名称,最多支持 256 个字符。

说明
  • ProductId 和 PicName 唯一确定一张图片。

  • 如果多次添加图片具有相同的 ProductId 和 PicName,以最后一次添加为准,前面添加的图片将被覆盖。

2092061_1.jpg

PicContent

string

是

图片内容。

  • 图片大小要求不超过 4 MB。

  • 图片格式:PNG、JPG、JPEG、BMP、GIF、WEBP、TIFF、PPM。

  • 传输等待时间不超过 5 秒。

  • 服务类型为商品图片搜索、通用图片搜索、家具家居图片搜索和工业五金图片搜索时,图片长和宽像素要求大于等于 100PX 且小于等于 4096PX。 服务类型为商标图片搜索时,图片长和宽像素要求大于等于 200PX 且小于 4096PX。 服务类型为布料图片搜索时,图片长和宽像素要求大于等于 448PX 且小于等于 4096PX。

  • 图片中不能包含旋转信息。

说明
  • 使用 SDK 方式调用:

  • 如使用 V3 版本 SDK,则无需填写 PicContent 字段,SDK 已将本字段封装为 PicContentObject 字段并自动转化为 Base64 编码。具体示例参考JAVA SDK。

  • SDK 不支持客户直接传递图片 URL,V3 版本 SDK 提供了一种变相实现 URL 上传的方式。具体示例参考JAVA SDK。

  • 使用阿里云 OpenAPI 平台调用:
    • 如使用2019-03-25版本,PicContent 字段请填写图片的 Base64 编码。

    • 如使用2020-12-14版本,在 PicContent 字段直接点击上传图片即可。

AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII=

CategoryId

integer

否

图片类目。具体请参考类目参考。

说明
  • 对于商品搜索,若设置类目,则以设置的为准;若不设置类目,将由系统进行类目预测,预测的类目结果可在 Response 中获取 。

  • 对于布料、商标、通用、家具家居和工业五金搜索,不论是否设置类目,系统会将类目设置为 88888888。

  • 对于通用搜索,不论是否设置类目,系统会将类目设置为 88888888。

88888888

Crop

boolean

否

是否需要进行主体识别。默认 true。

  • 为 true:由系统进行主体识别,以识别的主体进行搜索,主体识别结果可在 Response 中获取。

  • 为 false:则不进行主体识别,以整张图进行搜索。

对于布料图片搜索,此参数会被忽略,系统会以整张图进行搜索。

true

Region

string

否

图片的主体区域,格式为x1,x2,y1,y2, 其中x1,y1 是左上角的点,x2,y2是右下角的点。

说明
  • 若用户设置了 Region,则不论 Crop 参数为何值,都将以用户输入 Region 进行搜索。

  • 对于布料图片搜索,此参数会被忽略,系统会以整张图进行搜索。

  • Region 参数没有单位,是参考使用图片的长宽 PX 像素尺寸标记的结果,如果图片缩放对应 Region 参数值也要等比例缩放。

280,486,232,351

CustomContent

string

否

用户自定义的内容,最多支持 4096 个字符。

说明

查询时会返回该字段。例如可添加图片的描述等文本。

zidingyi

IntAttr

integer

否

整数类型属性,可用于查询时过滤,查询时会返回该字段。

22

StrAttr

string

否

字符串类型属性,最多支持 128 个字符。可用于查询时过滤,查询时会返回该字段。

说明

不支持特殊字符比如:\¥$&%

ss

IntAttr2

integer

否

整数类型属性,可用于查询时过滤,查询时会返回该字段。

22

StrAttr2

string

否

字符串类型属性,最多支持 128 个字符。可用于查询时过滤,查询时会返回该字段。

说明

不支持特殊字符比如:\¥$&%

ss

IntAttr3

integer

否

整数类型属性,可用于查询时过滤,查询时会返回该字段。

33

StrAttr3

string

否

字符串类型属性,最多支持 128 个字符。可用于查询时过滤,查询时会返回该字段。

说明

不支持特殊字符比如:\¥$&%

ss

IntAttr4

integer

否

整数类型属性,可用于查询时过滤,查询时会返回该字段。

44

StrAttr4

string

否

字符串类型属性,最多支持 128 个字符。可用于查询时过滤,查询时会返回该字段。

说明

不支持特殊字符比如:\¥$&%

ss

返回参数

名称

类型

描述

示例值

object

参数返回结果。

Message

string

错误信息。

说明

成功请求不返回数据,失败请求返回错误信息。

success

RequestId

string

请求 ID。

E0845DE6-52AF-4B50-9F15-51ED4044E6AB

Code

integer

错误码。

  • 0:成功。

  • 非 0:失败。

0

PicInfo

object

类目预测、主体识别结果。

Region

string

主体识别结果。图片的主体区域,格式为x1,x2,y1,y2,其中x1,y1是左上角的点,x2,y2是右下角的点。若用户请求中指定了主体区域,则以请求中为准。

94,691,206,650

CategoryId

integer

类目预测结果。若用户请求中指定了类目,则以请求中为准。

88888888

MultiRegion

array<object>

主体识别结果集合。

说明

需要版本升级至 V3.1.1 方可使用。

object

主体识别结果。

Region

string

主体识别结果。图片的主体区域,格式为 x1,x2,y1,y2,其中 x1,y1 是左上角的点,x2,y2 是右下角的点。若用户请求中指定了主体区域,则以请求中为准。

94,691,206,650

AllCategories

array<object>

系统支持的所有类目信息。

object

系统支持的所有类目信息。

Name

string

类目名称。

Other

Id

integer

类目 ID。

88888888

Success

boolean

请求是否成功。

true

示例

正常返回示例

JSON格式

{
  "Message": "success",
  "RequestId": "E0845DE6-52AF-4B50-9F15-51ED4044E6AB",
  "Code": 0,
  "PicInfo": {
    "Region": "94,691,206,650",
    "CategoryId": 88888888,
    "MultiRegion": [
      {
        "Region": "94,691,206,650"
      }
    ],
    "AllCategories": [
      {
        "Name": "Other",
        "Id": 88888888
      }
    ]
  },
  "Success": true
}

错误码

HTTP status code

错误码

错误信息

描述

400 BadRequest The request has invalid parameters. 无效的参数
400 InstanceStatusError Your instance is unavailable.
400 InvalidInstance The specified instance name is invalid. 实例名错误
400 NoCaretSeperator The body content is missing the ^ separator. 请求body缺少特定符号
400 EmptyMeta The body content has an empty meta field. 请求body含有空的字段
400 InvalidMetaItem The meta field is invalid. 无效的元信息字段
400 NoPicList The body content is missing the pic_list parameter. 未指定pic_list字段
400 NoSpecifiedPic The content of an image is not specified in the HTTP POST body. 图片未指定
400 NoSpecifiedSearchPic The search image is not specified.
400 InvalidCategory The specified category is invalid. 无效的类目id
400 OverflowMaxResultNum The specified number of total results exceeds the maximum of 500. 超过了最大的返回结果限制数500
400 OverflowMaxReturnNum The specified number of results for each request exceeds the maximum of 100. 单次返回数超过限制值100
400 InvalidStartParameter The specified parameter s is inavlid.
400 InvalidNumParameter The specified parameter n is invalid.
400 NoSpecifiedAddPic The image to insert is not specified.
400 NoSpecifiedItemId The item_id parameter is not specified.
400 InvalidIntAttr The specified int_attr field is invalid. 无效的int过滤字段
400 UnsupportedPicFormat The specified image format is invalid. 无效的图片格式
400 InvalidFilterClause The specified filtering condition is invalid. 无效的过滤条件
400 InstanceOverQuota The number of items exceeds the limit. 实例的图片数量超过限制值
400 IncorrectOrientation The image contains incorrect rotation flags in the meta data. 图片包含不支持的旋转参数
400 UnsupportedPicPixels The specified pixels is not supported. 图片像素值不支持
400 SearchTimeout The request is timed out.
400 PicNotExist The search picture does not exist.
400 NoSpecifiedProductId The parameter ProductId no specified.
400 NoSpecifiedPicName The parameter PicName no specified.
400 NoSpecifiedPicContent The parameter PicContent no specified.
400 InvalidType The specified parameter Type is not valid.
400 InvalidProductId The specified parameter ProductId is not valid.
400 InvalidPicName The specified parameter PicName is not valid.
400 InvalidStrAttr The specified parameter StrAttr is not valid. 无效StrAttr
400 InvalidCustomContent The specified parameter CustomContent is not valid.
400 InvalidPicContent The specified parameter PicContent length greater than 4 * 1024 * 1024.
400 TimeoutForTransferImage Timeout after 5 seconds waiting for images transfer to complete.
400 InvalidPicUrl The search picture does not exist at the specific url.
400 InvalidInstanceName The parameter instanceName is not specified.
400 InvalidRequestId The parameter requestId is not specified.
400 InvalidRequestIdTooLarge The parameter requestId is too large.
400 InvalidRegion The specific region is illegal.
400 RegionError region.
400 InvalidStrAttr2 The specified parameter StrAttr2 is not valid. 无效StrAttr2
400 InvalidStrAttr3 The specified parameter StrAttr3 is not valid. 无效StrAttr3
400 InvalidStrAttr4 The specified parameter StrAttr4 is not valid. 无效StrAttr4
400 InvalidIntAttr2 The specified parameter IntAttr2 is not valid. 无效IntAttr2
400 InvalidIntAttr3 The specified parameter IntAttr3 is not valid. 无效IntAttr3
400 InvalidIntAttr4 The specified parameter IntAttr4 is not valid. 无效IntAttr4
400 PictureError [download] Img Download Failed. 图片下载失败,请检查图片
400 UnsupportedOperationType The specified action is not supported. 内部错误:不支持的action
500 UnknownException An internal server error occurred. 未知异常
500 NetworkException A network error occurred. 内部错误:请求网络异常
500 RequestTimeout ​The request is timeout.
500 ExtractFeatureTimeout The request was timed out while extracting features.
500 AccessEngineFailed An error occurred while accessing the search engine.
500 InternalOssError An internal OAS error occurred. 内部错误:请求内部算法错误
500 InternalSwiftError An internal SWIFT error occurred. 内部错误:请求内部消息队列错误
500 InternalTableStoreError An internal Table Store error occurred. 内部错误:请求特征存储错误
500 ConnectionDVException Failed to obtain collection. internalError
403 NoPermission You are not authorized to perform this operation. 未授权的行为
403 DeniedRequest Your request was denied due to instance flow control. 请求被限流

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情。