CompareSimilarByImage - 相似度比较

更新时间:
复制 MD 格式

本接口用于对比两张图片相似值。

调试

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

调试

授权信息

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

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

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

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

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

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

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

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

操作

访问级别

资源类型

条件关键字

关联操作

imagesearch:CompareSimilarByImage

none

*全部资源

*

无 无

请求语法

POST  HTTP/1.1

请求参数

名称

类型

必填

描述

示例值

PrimaryPicContent

string

是

图片内容。

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

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

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

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

  • 服务类型为商标图片搜索时,图片长和宽像素要求大于等于 200PX 且小于 4096PX。

  • 服务类型为布料图片搜索时,图片长和宽像素要求大于等于 448PX 且小于等于 4096PX。

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

说明

使用 SDK 方式调用:- 仅支持 V3 版本 SDK,无需填写 PrimaryPicContent 字段,SDK 已将本字段封装为 PrimaryPicContentObject 字段并自动转化为 Base64 编码。具体示例参考 JAVA SDK。- SDK 不支持客户直接传递图片 URL,V3 版本 SDK 提供了一种变相实现 URL 上传的方式。具体示例参考 JAVA SDK。

AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII=

SecondaryPicContent

string

是

图片内容。

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

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

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

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

  • 服务类型为商标图片搜索时,图片长和宽像素要求大于等于 200PX 且小于 4096PX。

  • 服务类型为布料图片搜索时,图片长和宽像素要求大于等于 448PX 且小于等于 4096PX。

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

说明

使用 SDK 方式调用:- 仅支持 V3 版本 SDK,无需填写 PrimaryPicContent 字段,SDK 已将本字段封装为 PrimaryPicContentObject 字段并自动转化为 Base64 编码。具体示例参考JAVA SDK。- SDK 不支持客户直接传递图片 URL,V3 版本 SDK 提供了一种变相实现 URL 上传的方式。具体示例参考JAVA SDK。

AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII=

InstanceName

string

是

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

说明

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

demoinstance1

返回参数

名称

类型

描述

示例值

object

相似度计算结果。

Score

number

图片相似打分。取值范围:0~1。

0.85

Success

boolean

请求是否成功。

true

RequestId

string

请求 ID。

B3137727-7D6E-488C-BA21-0E034C38A879

Msg

string

错误信息。

success

AccessDeniedDetail

object

鉴权返回集合。

AuthAction

string

鉴权请求 Action。

xxx

AuthPrincipalDisplayName

string

鉴权主体信息。

111

AuthPrincipalOwnerId

string

鉴权主体的主账号 ID。

222

AuthPrincipalType

string

鉴权主体类型。

SubUser

EncodedDiagnosticMessage

string

加密后的完整诊断信息。

xxxxxx

NoPermissionType

string

ImplicitDeny:未命中任何策略。 ExplicitDeny:明确命中 Deny 策略。

ImplicitDeny

PolicyType

string

引起无权限的策略类型。

AccountLevelIdentityBasedPolicy

Code

integer

错误码。

  • 0:成功。

  • 非 0:失败。

0

示例

正常返回示例

JSON格式

{
  "Score": 0.85,
  "Success": true,
  "RequestId": "B3137727-7D6E-488C-BA21-0E034C38A879",
  "Msg": "success",
  "AccessDeniedDetail": {
    "AuthAction": "xxx",
    "AuthPrincipalDisplayName": "111",
    "AuthPrincipalOwnerId": "222",
    "AuthPrincipalType": "SubUser",
    "EncodedDiagnosticMessage": "xxxxxx",
    "NoPermissionType": "ImplicitDeny",
    "PolicyType": "AccountLevelIdentityBasedPolicy"
  },
  "Code": 0
}

错误码

HTTP status code

错误码

错误信息

描述

400 SearchTimeout The request timed out. 请求超时
400 TimeoutForTransferImage Image transfer timed out. 客户端图片传输超时
400 UnsupportedPicFormat The specified image format is invalid. 无效的图片格式
400 UnsupportedPicPixels The specified pixels is not supported. 图片像素值不支持
400 UnsupportedPictureFormat The format of the specified picture is not supported. 用户图片格式不支持
400 Console.InstanceNotFound The specified ImageSearch instance is not found. 查找不到实例,检查购买的实例ID是否正确。
400 Console.PidError The number of PID bindings of the current instance exceeds 50. 当前实例PID绑定数量超过50
400 EmptyMeta The body content has an empty meta field. 请求body含有空的字段
400 IncorrectOrientation The image contains incorrect rotation flags in the meta data. 图片包含不支持的旋转参数
400 InstanceOverQuota The number of items exceeds the limit. 实例的图片数量超过限制值
400 InstanceStatusError The current instance status does not support this operation. 实例状态不可用
400 InvalidInstance The specified instance name is invalid. 实例名错误
400 InvalidPicContent The image size exceeds 4 MB. 图片大小超过4M
400 InvalidPicUrl The specified parameter PicUrl is not valid. 无效的PicUrl参数
400 NeedRegisterBeforeInvoke Register for PID before invoking the service. 调用前需要先注册pid
400 NoCaretSeperator The body content is missing the ^ separator. 请求body缺少特定符号
400 NoSpecifiedPic The content of an image is not specified in the HTTP POST body. 图片未指定
400 PicNotExist The specified image does not exist. 图片未指定
400 InvalidSecondaryPicContent The specified parameter SecondaryPicContent is not valid. 无效的SecondaryPicContent参数
400 InvalidPrimaryPicContent The specified parameter PrimaryPicContent is not valid. 无效的PrimaryPicContent参数
400 PictureError [download] Img Download Failed. 图片下载失败,请检查图片
400 UnsupportedOperationType The specified action is not supported. 内部错误:不支持的action
400 UnsupportedInstanceType The instance type is not supported. 内部错误:不支持的实例类型
500 ServerInternalError An internal error occurred. 系统内部错误
500 UnknownException An internal server error occurred. 未知异常
500 AccessEngineFailed An error occurred while accessing the search engine.
500 ConnectionDVException Failed to obtain collection. internalError
500 Console.CallServiceError An internal service error occurred. 访问内部服务错误
500 ExtractFeatureTimeout The request timed out while extracting features. 内部错误:提取特征超时
500 InternalOssError An internal OAS error occurred. 内部错误:请求内部算法错误
500 InternalSwiftError An internal SWIFT error occurred. 内部错误:请求内部消息队列错误
500 InternalTableStoreError An internal Table Store error occurred. 内部错误:请求特征存储错误
500 NetworkException A network error occurred. 内部错误:请求网络异常
500 RequestTimeout The request timed out. 内部错误:请求超时
403 Console.NoPermissionError You are not authorized to perform this operation. 你没有权限进行该操作
403 Console.NotAllowedModifyToken You are not allowed to modify token today. 今天不允许用户修改该token值
403 DeniedRequest Your request was denied due to instance flow control. 请求被限流
403 NoPermission You are not authorized to perform this operation. 未授权的行为
409 Console.TaskAlreadyExist A task that is in progress already exists. 已经存在正在运行的任务。

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

变更历史

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