Table of Contents

搜索識別目標| POST /v2/search

搜索圖像目標,以圖搜圖識別接口。

Action

POST /v2/search

認證

需要

Http Header

Content-Type : multipart/form-data

Authorization (僅當採用 API Key Token 方式認證)

請求參數

Field Type Required Description
image Multipart Yes 圖像內容的 base64 編碼字符串,支持 JPG 和 PNG 格式圖像。
notracking String No "false" 表示返回 trackingImage 跟蹤圖像。"true" 表示僅返回檢測到的 targetId 屬性,不返回跟蹤圖像。WebAR 默認建議帶上降低請求延遲。

Token 認證的請求示例

curl -X POST -H "Authorization:xxx"  --form "image=@trackingImage.jpg;type=image/jpg"  --form appId=YOUR-APPID 
          https://<your-domain>-cn1.crs.easyar.com:8443/v2/search

簽名認證請求示例

curl -X POST --form "image=@trackingImage;type=image/jpg" 
              --form apiKey=YOUR-APIKEY  --form appId=YOUR-APPID 
              --form timestamp=1514736000000 
              --form signature=xxx 
          https://<your-domain>-cn1.crs.easyar.com:8443/v2/search
重要事項
  • 一定要使用 Client-end-URL 纔是識別入口,https 是 8443 端口
  • http header 設置 Connection: Keep-Alive 優化重複連接開銷

返回字段

字段 描述
statusCode 狀態碼 0 表示認證正確,更多參考 狀態碼
result 錯誤消息,或者目標圖信息
timestamp 響應返回時的服務器端時間。使用 Unix 時間戳格式,以毫秒爲單位
result.targetId 目標圖的唯一 ID
result.trackingImage 跟蹤圖像的 base64 編碼字符串
result.name 目標名稱
result.size 識別圖寬度(單位 cm )。識別圖的高度將由系統根據您上傳的圖片自動計算。識別圖的大小和疊加虛擬內容的大小對應
result.meta base64 編碼的附加信息,例如將 json 字符串 base64 編碼後生成的字符串
result.type 固定爲 ImageTarget
result.active "1" 啓用,"0" 停用

主要返回碼

Response HTTPCODE Status Result
OK 200 0 result: { imageBody }
NO_RESULT 404 17 result: { message: "No result: there is no matching." }
NO_TARGET 500 18 result: { message: "Target not found: there is a matching but no target, please report this issue: IMAGE-UUID" }
TIMEOUT 408 19 result: { message: "Request timeout." }
OUT_OF_LIMIT 402 21 result: { message: "You have exceeded the limit of daily scanning." }
OUT_OF_QPS 200 21 result: { message: "Exceed your QPS limitation." }
RPC_ERROR 500 20 result: { message: "Error retrieving results." }
OTHER_ERROR 501 30 result: { message: "Other error occur: details" }

錯誤碼

參見 狀態碼以及錯誤碼大全

請求示例

POST /search/ HTTP/1.1
Host:
Date: Mon, 1 Jan 2018 00:00:00 GMT
Content-Type: application/json
{
    "image":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgM...",
    "timestamp": 1514736000000,
    "appKey": "test_app_key",
    "signature": "89985e2420899196db5bdf16b3c2ed0922c0c221"
}

返回示例

  • 如果命中識別到,返回結構如圖:

    HTTP/1.1 200 OK
    Content-Type: application/json
    {
        "statusCode": 0,
        "result": {
          "target": {
            "targetId":"e61db301-e80f-4025-b822-9a00eb48d8d2",
            "trackingImage":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgM...",
            "name": "easyar",
            "size": "5",
            "meta": "496fbbabc2b38ecs3460a...",
            "type": "ImageTarget",
            "modified":1514735000000
            "active":"1",
            "trackableRate": 0,
            "detectableRate": 0,
            "detectableDistinctiveness":0,
            "detectableFeatureCount": 0,
            "trackableDistinctiveness": 0,
            "trackableFeatureCount": 0,
            "trackableFeatureDistribution": 0,
            "trackablePatchContrast": 0,
            "trackablePatchAmbiguity": 0
          }
        },
        "timestamp": 1514736000000
    }

  • 如果沒有匹配的目標圖,返回示例如下:

    HTTP/1.1 404 NOT FOUND
    Content-Type: application/json
    {
      "statusCode": 17,
      "result": {
        "message": "No result: there is no matching."
      }
    }