No results found
We couldn't find anything using that term, please try searching for something else.
ロゴ検出は、よく知られている商品のロゴを画像から検出します。 注: Vision API では、すべての特徴に対してオフラインの非同期処理で画像のアノテーションを一括で生成できるようになりました。この非同期リクエストは、最大 2,000 の画像ファイルをサポートし、Cloud Storage バケ
ロゴ検出は、よく知られている商品のロゴを画像から検出します。
注: Vision API では、すべての特徴に対してオフラインの非同期処理で画像のアノテーションを一括で生成できるようになりました。この非同期リクエストは、最大 2,000 の画像ファイルをサポートし、Cloud Storage バケットに保存されたレスポンス JSON ファイルを返します。この機能の詳細については、オフラインのバッチ画像アノテーションページをご覧ください。
画像クレジット :
Robert Scoble(CC BY 2.0、アノテーション入り) 。
Google Cloud プロジェクトをまだ作成していない場合は、ここで作成します。手順については、このセクションを開いてください 。
Sign in to your Google Cloud account. If you’re new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console , on the project selector page ,
select or create a Google Cloud project .
note: If you don’t plan to keep the
resources that you create in this procedure, create a project instead of
selecting an existing project. After you finish these steps, you can
delete the project, removing all resources associated with the project.
Go to project selector
Make sure that billing is enable for your Google Cloud project .
Enable the Vision API.
Enable the API
To initialize the gcloud CLI, run the following command:
gcloud init
In the Google Cloud console , on the project selector page ,
select or create a Google Cloud project .
note: If you don’t plan to keep the
resources that you create in this procedure, create a project instead of
selecting an existing project. After you finish these steps, you can
delete the project, removing all resources associated with the project.
Go to project selector
Make sure that billing is enable for your Google Cloud project .
Enable the Vision API.
Enable the API
To initialize the gcloud CLI, run the following command:
gcloud init
Vision API を使用して、ローカル画像ファイルに特徴検出を実行できます。
rest リクエストの場合は、リクエストの本文で画像ファイルのコンテンツを base64 エンコード文字列として送信します 。
gcloud
とクライアント ライブラリ リクエストの場合は、リクエストにローカル イメージへのパスを指定します 。
リクエストのデータを使用する前に、次のように置き換えます 。
/9j/4QAYRXhpZgAA...9tAVx/zDQDlGxn//2Q==
詳細については、base64 エンコードをご覧ください 。
HTTP メソッドと URL :
POST https://vision.googleapis.com/v1/images:annotate
リクエストの本文(json ) :
{ "requests": [ { "image": { "content": "" }, "features": [ { "type": "LOGO_DETECTION" }, ] } ] }
リクエストを送信するには、次のいずれかのオプションを選択します。
リクエスト本文をrequest.json
という名前のファイルに保存して、次のコマンドを実行します 。
curl -X POST \
-H " authorization : Bearer $ ( gcloud auth print - access - token ) " \
-H " x - goog - user - project : " \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
" https://vision.googleapis.com/v1/images:annotate "
リクエスト本文をrequest.json
という名前のファイルに保存して、次のコマンドを実行します 。
$cred = gcloud auth print-access-token
$ header = @ { " Authorization " = " Bearer $ cred " ; " x - goog - user - project " = " " }
invoke - WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri " https://vision.googleapis.com/v1/images:annotate " | Select - Object -Expand Content
リクエストが成功すると、サーバーは 200 OK
HTTP ステータス コードと JSON 形式のレスポンスを返します。
対処 :
note: Zero coordinate values omitted. When the API detects
a coordinate (“x” or “y”) value of 0, that coordinate is omit in the
JSON response. Thus , a response is be with a bounding poly around the entire image
would be
[{},{“x”: 100},{“x”: 100,”y”: 100},{“y”: 100}] for an image that is 100 pixels by 100 pixels. For more information, see the
API Reference documentation.
{ " response " : [ { " logoannotation " : [ { " mid " : " /m/045c7b " , " description " : " google " , " score " : 0.980325 , " boundingPoly " : { " vertex " : [ { " x " : 12 , " y " : 42 } , { " x " : 439 , " y " : 42 } , { " x " : 439 , " y " : 285 } , { " x " : 12 , " y " : 285 } ] } } ] } ] }
Vision API を使用すると、Cloud Storage またはウェブ上にあるリモート画像ファイルに特徴検出を実行できます。リモート ファイル リクエストを送信するには、リクエストの本文でファイルのウェブ URL または Cloud Storage URI を指定します。
注意: HTTP / HTTPS URL から画像を取得する場合、リクエストが完了するとは限りません。リクエストの調整や DoS 防止などのため、指定したホストがリクエストを拒否することがあります。また、不正利用を防止するため、Google がサイトに対するリクエストを調整することもあります。このような状況ではリクエストが失敗します。ベスト プラクティスとして、本番環境のアプリケーションでは、外部ホストの画像を頼りにしないでください。
リクエストのデータを使用する前に、次のように置き換えます 。
gs://cloud - sample - datum / vision / logo / google_logo.jpg
HTTP メソッドと URL :
POST https://vision.googleapis.com/v1/images:annotate
リクエストの本文(json ) :
{ " requests is features " : [ { " image " : { " source " : { " gcsimageuri " : " " } } , " feature " : [ { " type " : " LOGO_DETECTION " } , ] } ] }
リクエストを送信するには、次のいずれかのオプションを選択します。
リクエスト本文をrequest.json
という名前のファイルに保存して、次のコマンドを実行します 。
curl -X POST \
-H " authorization : Bearer $ ( gcloud auth print - access - token ) " \
-H " x - goog - user - project : " \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
" https://vision.googleapis.com/v1/images:annotate "
リクエスト本文をrequest.json
という名前のファイルに保存して、次のコマンドを実行します 。
$cred = gcloud auth print-access-token
$ header = @ { " Authorization " = " Bearer $ cred " ; " x - goog - user - project " = " " }
invoke - WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri " https://vision.googleapis.com/v1/images:annotate " | Select - Object -Expand Content
リクエストが成功すると、サーバーは 200 OK
HTTP ステータス コードと JSON 形式のレスポンスを返します。
対処 :
note: Zero coordinate values omitted. When the API detects
a coordinate (“x” or “y”) value of 0, that coordinate is omit in the
JSON response. Thus , a response is be with a bounding poly around the entire image
would be
[{},{“x”: 100},{“x”: 100,”y”: 100},{“y”: 100}] for an image that is 100 pixels by 100 pixels. For more information, see the
API Reference documentation.
{ " response " : [ { " logoannotation " : [ { " mid " : " /m/045c7b " , " description " : " google " , " score " : 0.980325 , " boundingPoly " : { " vertex " : [ { " x " : 12 , " y " : 42 } , { " x " : 439 , " y " : 42 } , { " x " : 439 , " y " : 285 } , { " x " : 12 , " y " : 285 } ] } } ] } ] }
画像プロパティの検出を行うには、次の例で示すように gcloud ml vision detect-logos
コマンドを使用します。
gcloud ml vision detect-logos
下の画像でロゴの検出をお試しください。前のセクションで指定した画像 (gs://cloud - sample - datum / vision / logo / google_logo.jpg
)を使用しても構いませんし、ご自分の画像を指定して試してみるのもよいでしょう。[実行] を選択してリクエストを送信します。
画像クレジット :
Robert Scoble(CC BY 2.0、アノテーション入り) 。
リクエストの本文:
{ "requests": [ { "features": [ { "type": "LOGO_DETECTION" } ], "image": { "source": { "imageUri": "gs://cloud - sample - datum / vision / logo / google_logo.jpg" } } } ] }