LoginSignup
4
4

More than 5 years have passed since last update.

Google Cloud Vision API のjsonの階層を調べてみた(人の画像)

Last updated at Posted at 2016-09-28

この度GCP(Google Cloud Platform)のGoogle Cloud Vision APIのアプリケーション開発において、json型で帰ってくるデータを調べてみた。

Google Cloud Vision API の階層構成

※value -> 値
※text -> 文字列

1階層目
responses

2階層目
faceAnnotations
labelAnnotations[3]
safeSearchAnnotation
imagePropertiesAnnotation

3階層目(faceAnnotations)
boundingPoly
fbBoundingPoly
landmarks[34]

rollAngle : [value]
panAngle : [value]
titAngle : [value]
detectionConfidence : [value]
landmarkingConfidence : [value]

joyLikelihood : [text]
sorrowLikelihood : [text]
angerLikelihood : [text]
surpriseLikelihood : [text]
underExposedLikelihood : [text]
blurredLikelihood : [text]
headwearLikelihood : [text]

3階層目(labelAnnotations)
mid : [text]
description : [text]
score : [value]

3階層目(safeSearchAnnotation)
adult : [text]
spoof : [text]
medical : [text]
violence : [text]

3階層目(imagePropertiesAnnotation)
dominantColors

4階層目(boundingPoly, fbBoundingPoly)
vertices

4階層目(landmarks)
type : [text]
position

4階層目(dominantColors)
colors

5階層目(vertices)
x : [value]
~[3][4]y : [value]

5階層目(position)
x : [value]
y : [value]
z : [value]

5階層目(colors)
color[3]
score : [value]
pixelFraction : [value]

6階層目(color)
red : [value]
green : [value]
blue : [value]

追記
階層ごとに分けてはいましたが、その説明がなかったので追記します。

階層ごとの役割

第1階層

1階層目
responses
この階層は取得したデータの全てが入ります。


第2階層

2階層目
faceAnnotations
顔検出された時に生成される配列

labelAnnotations[3]
画像で読み取ったものが何であるかの判定
ex: person, face ...など

safeSearchAnnotation
有害な画像でないかの項目

imagePropertiesAnnotation
画像の色解析


第3階層

3階層目(faceAnnotations)
boundingPoly
顔の輪郭を検出

fbBoundingPoly
皮膚が含まれる範囲を検出

landmarks[34]
顔の各パーツ

rollAngle : [value]
顔の傾きを示す。-180 ~ 180の範囲で表される。

panAngle : [value]
顔が左右どちらを向いてるかを表す。-180 ~ 180の範囲で表される。

titAngle : [value]
顔が上下どちらを向いてるかを表す。-180 ~ 180の範囲で表される。

detectionConfidence : [value]
顔検出の精度。0 ~ 1の間で表す。

landmarkingConfidence : [value]
顔の各パーツ。0 ~ 1の間で表す。

joyLikelihood : [text]
楽しみの度合い

sorrowLikelihood : [text]
悲しみの度合い

angerLikelihood : [text]
怒りの度合い

surpriseLikelihood : [text]
驚きの度合い

underExposedLikelihood : [text]
肌の露出の度合い

blurredLikelihood : [text]
ぼやけの度合い

headwearLikelihood : [text]
何かを被っているかの度合い

3階層目(labelAnnotations)
mid : [text]
ナレッジグラフのエンティティID

description : [text]
カテゴリ名

score : [value]
検出の信頼度

3階層目(safeSearchAnnotation)
adult : [text]
アダルトコンテンツの度合い

spoof : [text]
パロディ画像の検出

medical : [text]
医療要素の度合い。臓器など

violence : [text]
暴力性の度合い

3階層目(imagePropertiesAnnotation)
dominantColors
画像自体の配色を支配する色


第4階層

4階層目(boundingPoly, fbBoundingPoly)
vertices
範囲を示すポリゴン

4階層目(landmarks)
type : [text]
パーツを表すコード

position
パーツの位置情報

4階層目(dominantColors)
colors
色の情報


第5階層

5階層目(vertices)
x : [value]
画像の左上を基準としたX座標(px)

~[3][4]y : [value]
画像の左上を基準としたY座標(px)

5階層目(position)
x : [value]
画像の左端から右方向への距離

y : [value]
画像の上端から下方向への距離

z : [value]
手前、前後の距離

5階層目(colors)
color[3]
色情報

score : [value]
検出の信頼度。0 ~ 1の間で表す。

pixelFraction : [value]
ピクセルの大きさ


第6階層

6階層目(color)
red : [value]
赤色の輝度

green : [value]
緑色の輝度

blue : [value]
青色の輝度

データの違い

上のjsonの階層はimageファイルが人だった時の一覧である。
しかし読み込むデータによっては異なることもあるので注意が必要である。

例 : imageが犬の場合だと

2階層目
ここがなくなる -> //faceAnnotations
labelAnnotations[3]
safeSearchAnnotation
imagePropertiesAnnotation

感想

まだ調べ始めではあるがGCPは驚異的だった。写真によっては文字も読み取ることも可能という有能性
これからももっと調べていこうと思っている。

4
4
3

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
4
4