16
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GoogleCloudVisionをPythonで試すための最初の手順

Posted at

関西おうちハック トライ 2016 vol.1でGoogleCloudVisionを触ってみたのでその覚書き。

環境はMacから、ターミナルで。

基本的にはGoogleのGettingStartをおってます。
https://cloud.google.com/vision/docs/getting-started

まずはGCPからCloudVisionを有効化
スクリーンショット 2016-02-20 19.46.29.png

認証情報 > Create credentials > サービスアカウントキー > JSON > 作成
の手順で進む。ここでダウンロードされるJSONファイルを保存しておく。
スクリーンショット 2016-02-20 20.31.16.png

Pythonでgoogleapiclientを使ってFace Detection APIを実行する

まずはターミナルから環境変数を定義。
export GOOGLE_APPLICATION_CREDENTIALS='/xxx/xxx/{先ほどのJSONファイル}.json'

次にgithubからソースをcloneします。
https://github.com/GoogleCloudPlatform/cloud-vision

cloneしたディレクトリからpython > face_detection内に移動、
その中のfaces.pyを実行します。引数に解析にかけたい画像ファイルを指定します。

python faces.py face-input.jpg

同階層にout.jpgが出力されればOKです。

顔認識関係にはFaceAnnotation

取得できる情報はここを参照→https://cloud.google.com/vision/reference/rest/v1/images/annotate#FaceAnnotation

表情だけでなく、口の位置や顔の座標をxyz軸で取得出来るのと複数の顔に対応しているようでしかもAPIたたくだけなのでもっといろいろ試したくなります。
月1000ユニットまで無料。顔認識だけなら1000回実行出来ます。

16
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?