Vision API Product Search では、検索画像内にある単一の商品を検出し、それに対応する商品を示すことができます。また、画像内に複数の商品が存在する場合は、それらを特定して対応する商品のリストを取得することもできます。
単一の商品の画像とレスポンス
この検索画像には単一の商品が含まれています。
Vision API Product Search を使用して類似商品を検索すると、画像内の 2 つの境界ボックス(一つは商品を囲むボックス、もう一つは画像全体を囲むボックス)を示すレスポンスが返されます。
レスポンス全体を見るには、下のセクションを開いてください。
完全なレスポンス
{ "responses": [ { "productSearchResults": { "indexTime": "2018-12-04T22:33:53.673600055Z", "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id16", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 1, "image": "projects/project-id/locations/location-id/products/product_id16/referenceImages/image16" }, { "product": { "name": "projects/project-id/locations/location-id/products/product_id29", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.34263745, "image": "projects/project-id/locations/location-id/products/product_id29/referenceImages/image29" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id89", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.20485385, "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89" } ], "productGroupedResults": [ { "boundingPoly": { "normalizedVertices": [ { "x": 0.25610325, "y": 0.1357359 }, { "x": 0.77213204, "y": 0.1357359 }, { "x": 0.77213204, "y": 0.9287346 }, { "x": 0.25610325, "y": 0.9287346 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id16", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 1, "image": "projects/project-id/locations/location-id/products/product_id16/referenceImages/image16" }, { "product": { "name": "projects/project-id/locations/location-id/products/product_id29", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.3345438, "image": "projects/project-id/locations/location-id/products/product_id29/referenceImages/image29" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id76", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "shoe" } ] }, "score": 0.20218614, "image": "projects/project-id/locations/location-id/products/product_id76/referenceImages/image76" } ] }, { "boundingPoly": { "normalizedVertices": [ {}, { "x": 1 }, { "x": 1, "y": 1 }, { "y": 1 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id16", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 1, "image": "projects/project-id/locations/location-id/products/product_id16/referenceImages/image16" }, { "product": { "name": "projects/project-id/locations/location-id/products/product_id29", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.3507311, "image": "projects/project-id/locations/location-id/products/product_id29/referenceImages/image29" }, { "product": { "name": "projects/project-id/locations/location-id/products/product_id8", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.26709077, "image": "projects/project-id/locations/location-id/products/product_id8/referenceImages/image8" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id51", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.21597815, "image": "projects/project-id/locations/location-id/products/product_id51/referenceImages/image51" } ] } ] } } ] }
境界ボックスと対応する商品
リクエストに対して返された 2 組の頂点によって、画像内で次の 2 つの商品(境界ボックス)が指定されています。
Vision API Product Search で識別されたボックスごとに、対応する商品のリストが返されます。
API のレスポンスでは、一致する商品の結果と境界ボックスは productGroupedResults
フィールドに一覧表示されます。それらは、画像内で検出された商品ごとにグループ化されます。それぞれの boundingPoly
エントリには、正規化された頂点(0 から 1 のスケールであり、画像の実際のピクセル値には対応していません)によって指定されたリージョンのリストが含まれます。その特定の領域に対応する商品のリストが返されます。
レスポンスの次のセクションは、洋服を囲んだ境界ボックスに対応しています。
単一の商品ボックスのレスポンス セクション
.... "productGroupedResults": [ { "boundingPoly": { "normalizedVertices": [ { "x": 0.25610325, "y": 0.1357359 }, { "x": 0.77213204, "y": 0.1357359 }, { "x": 0.77213204, "y": 0.9287346 }, { "x": 0.25610325, "y": 0.9287346 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id16", "displayName": " ", "productCategory": "apparel", "productLabels":... "score": 1, ...
results
フィールドの後に対応する商品のリストが返され、一致スコアの降順でランク付けされます。スコアの範囲は 0(最低の信頼度)から 1(最高の信頼度)です。
レスポンスで返されるもう一方の boundingPoly
は画像全体を囲んでいます。その正規化された頂点は次のように示されます。
[{},{"x": 1},{"x": 1,"y": 1},{"y": 1}]
座標値が 0 の場合、省略されます。したがって、上で指定された境界ポリゴンは次の座標に対応します。
[{"x": 0,"y": 0},{"x": 1, "y": 0},{"x": 1,"y": 1},{"y": 1}]
続いて、この境界ボックス(画像全体)に対応する商品のリストが同様に返されます。
複数商品の画像(マルチ検出)とレスポンス
次の検索画像には複数の商品が含まれています。
Vision API Product Search を使用して類似商品を検索すると、画像内の複数の境界ボックス(1 つは画像全体、残り 3 つは 3 着の洋服それぞれを囲むボックス)を示すレスポンスが返されます。
レスポンス全体を見るには、下のセクションを開いてください。
完全なレスポンス
{ "responses": [ { "productSearchResults": { "indexTime": "2018-12-05T18:34:22.231193168Z", "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id89", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.40636745, "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89" }, { "product": { "name": "projects/project-id/locations/location-id/products/product_id56", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.35433072, "image": "projects/project-id/locations/location-id/products/product_id56/referenceImages/image56" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id92", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.30736163, "image": "projects/project-id/locations/location-id/products/product_id92/referenceImages/image92" } ], "productGroupedResults": [ { "boundingPoly": { "normalizedVertices": [ { "x": 0.38727918, "y": 0.10391616 }, { "x": 0.57177967, "y": 0.10391616 }, { "x": 0.57177967, "y": 0.94973093 }, { "x": 0.38727918, "y": 0.94973093 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id39", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.36689043, "image": "projects/project-id/locations/location-id/products/product_id39/referenceImages/image39" }, { "boundingPoly": { "normalizedVertices": [ { "x": 0.63010275, "y": 0.08650439 }, { "x": 0.88989735, "y": 0.08650439 }, { "x": 0.88989735, "y": 0.9285545 }, { "x": 0.63010275, "y": 0.9285545 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id89", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.4007347, "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id30", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.27045864, "image": "projects/project-id/locations/location-id/products/product_id30/referenceImages/image30" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id63", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.23139484, "image": "projects/project-id/locations/location-id/products/product_id63/referenceImages/image63" } ] }, ... { "boundingPoly": { "normalizedVertices": [ {}, { "x": 1 }, { "x": 1, "y": 1 }, { "y": 1 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id30", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.39522344, "image": "projects/project-id/locations/location-id/products/product_id30/referenceImages/image30" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id4", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.34226564, "image": "projects/project-id/locations/location-id/products/product_id4/referenceImages/image4" } ] }, { "boundingPoly": { "normalizedVertices": [ { "x": 0.030102689, "y": 0.067680866 }, { "x": 0.28942674, "y": 0.067680866 }, { "x": 0.28942674, "y": 0.94973093 }, { "x": 0.030102689, "y": 0.94973093 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id89", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.42439392, "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id51", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.26797917, "image": "projects/project-id/locations/location-id/products/product_id51/referenceImages/image51" } ] } ] } } ] }
境界ボックスと対応する商品
次の画像には、この複数商品の画像内で Vision API Product Search によって識別されたすべての境界ボックスが示されています。
単一商品の画像と同様に、複数商品の画像のレスポンスでは、境界ボックスとそれに対応する商品の結果のリストが productGroupedResults
フィールドに返されます。それぞれの商品は境界ポリゴンで識別され、対応する商品は検出された商品ごとにグループ化されます。
レスポンスの次のセクションは、中央の洋服を囲む境界ボックスに対応しています。
商品ボックスのレスポンス セクション(中央の洋服)
"productGroupedResults": [ { "boundingPoly": { "normalizedVertices": [ { "x": 0.38727918, "y": 0.10391616 }, { "x": 0.57177967, "y": 0.10391616 }, { "x": 0.57177967, "y": 0.94973093 }, { "x": 0.38727918, "y": 0.94973093 } ] }, "results": [ { "product": { "name":... "score": 0.36689043, ...
次の画像は、Vision API Product Search によって返された中央の洋服に対応するいくつかの商品を示したものです。
画像内には他にも次の境界ボックスがあります。それぞれに対応する商品のリストも返されます(ここには含まれていません)。
- 左のドレス:
{"x":0.03, "y":0.07},{"x":0.29, "y":0.07},{"x":0.29, "y":0.95},{"x":0.03, "y":0.95}
- 右のドレス:
{"x":0.63, "y":0.09},{"x":0.89, "y":0.09},{"x":0.89, "y":0.93},{"x":0.63, "y":0.93}
- 画像全体:
{},{"x": 1},{"x": 1,"y": 1},{"y": 1}
、また次のようにも表されます。{"x": 0, "y": 0},{"x": 1,"y:0"},{"x": 1,"y": 1},{"x": 0,"y": 1}