Cloud Vision APIをPHPから使ってみた。その③
前回はCloud Vision APIにPHP側からリクエストを投げるところまでを行いましたので、
今回はレスポンスの結果を確認していきたいと思います。
レスポンス内容
まずはレスポンス内容を見てみましょう。
今回はFACE_DETECTIONのみを指定していますので、FACE関連の内容しか出てきませんが、
他のDETECTIONも指定すると、もっと沢山出てきます。
{
"responses": [
{
"faceAnnotations": [
{
"angerLikelihood": "UNLIKELY",
"blurredLikelihood": "VERY_UNLIKELY",
"boundingPoly": {
"vertices": [
{
"x": 277,
"y": 44
},
{
"x": 421,
"y": 44
},
{
"x": 421,
"y": 212
},
{
"x": 277,
"y": 212
}
]
},
"detectionConfidence": 0.89532435,
"fdBoundingPoly": {
"vertices": [
{
"x": 303,
"y": 83
},
{
"x": 399,
"y": 83
},
{
"x": 399,
"y": 179
},
{
"x": 303,
"y": 179
}
]
},
"headwearLikelihood": "VERY_UNLIKELY",
"joyLikelihood": "VERY_UNLIKELY",
"landmarkingConfidence": 0.71623695,
"landmarks": [
{
"position": {
"x": 332.76343,
"y": 113.692245,
"z": 0.0010525604
},
"type": "LEFT_EYE"
},
{
"position": {
"x": 369.34872,
"y": 113.70369,
"z": -0.04455744
},
"type": "RIGHT_EYE"
},
{
"position": {
"x": 315.5745,
"y": 103.84334,
"z": 4.8573413
},
"type": "LEFT_OF_LEFT_EYEBROW"
},
{
"position": {
"x": 340.6877,
"y": 100.55593,
"z": -6.7010517
},
"type": "RIGHT_OF_LEFT_EYEBROW"
},
{
"position": {
"x": 360.66492,
"y": 100.841,
"z": -6.675439
},
"type": "LEFT_OF_RIGHT_EYEBROW"
},
{
"position": {
"x": 385.28314,
"y": 104.174805,
"z": 4.846083
},
"type": "RIGHT_OF_RIGHT_EYEBROW"
},
{
"position": {
"x": 350.5497,
"y": 111.564865,
"z": -8.780574
},
"type": "MIDPOINT_BETWEEN_EYES"
},
{
"position": {
"x": 350.6659,
"y": 133.53343,
"z": -25.98531
},
"type": "NOSE_TIP"
},
{
"position": {
"x": 350.88446,
"y": 152.79016,
"z": -18.262651
},
"type": "UPPER_LIP"
},
{
"position": {
"x": 350.79382,
"y": 168.62276,
"z": -17.48801
},
"type": "LOWER_LIP"
},
{
"position": {
"x": 337.01038,
"y": 162.19357,
"z": -8.738847
},
"type": "MOUTH_LEFT"
},
{
"position": {
"x": 364.25076,
"y": 161.97086,
"z": -8.87977
},
"type": "MOUTH_RIGHT"
},
{
"position": {
"x": 350.7603,
"y": 160.12784,
"z": -16.026594
},
"type": "MOUTH_CENTER"
},
{
"position": {
"x": 361.30548,
"y": 139.67697,
"z": -9.994327
},
"type": "NOSE_BOTTOM_RIGHT"
},
{
"position": {
"x": 341.03574,
"y": 139.70354,
"z": -10.173845
},
"type": "NOSE_BOTTOM_LEFT"
},
{
"position": {
"x": 350.99435,
"y": 141.5242,
"z": -16.810558
},
"type": "NOSE_BOTTOM_CENTER"
},
{
"position": {
"x": 327.90234,
"y": 110.401825,
"z": -2.1700659
},
"type": "LEFT_EYE_TOP_BOUNDARY"
},
{
"position": {
"x": 339.141,
"y": 114.66393,
"z": 0.17736068
},
"type": "LEFT_EYE_RIGHT_CORNER"
},
{
"position": {
"x": 331.3952,
"y": 117.13222,
"z": -0.74573904
},
"type": "LEFT_EYE_BOTTOM_BOUNDARY"
},
{
"position": {
"x": 319.67868,
"y": 114.63684,
"z": 4.0833383
},
"type": "LEFT_EYE_LEFT_CORNER"
},
{
"position": {
"x": 327.14227,
"y": 113.88191,
"z": -0.55243915
},
"type": "LEFT_EYE_PUPIL"
},
{
"position": {
"x": 372.6692,
"y": 110.03074,
"z": -2.2177434
},
"type": "RIGHT_EYE_TOP_BOUNDARY"
},
{
"position": {
"x": 379.61917,
"y": 113.85382,
"z": 3.70754
},
"type": "RIGHT_EYE_RIGHT_CORNER"
},
{
"position": {
"x": 369.88336,
"y": 116.95369,
"z": -0.7889224
},
"type": "RIGHT_EYE_BOTTOM_BOUNDARY"
},
{
"position": {
"x": 361.6826,
"y": 114.54378,
"z": 0.1364616
},
"type": "RIGHT_EYE_LEFT_CORNER"
},
{
"position": {
"x": 373.2228,
"y": 113.504074,
"z": -0.6530298
},
"type": "RIGHT_EYE_PUPIL"
},
{
"position": {
"x": 325.837,
"y": 97.099304,
"z": -2.0782194
},
"type": "LEFT_EYEBROW_UPPER_MIDPOINT"
},
{
"position": {
"x": 374.49063,
"y": 96.73857,
"z": -2.1848493
},
"type": "RIGHT_EYEBROW_UPPER_MIDPOINT"
},
{
"position": {
"x": 300.00845,
"y": 145.06592,
"z": 50.649952
},
"type": "LEFT_EAR_TRAGION"
},
{
"position": {
"x": 397.4974,
"y": 143.11761,
"z": 48.0778
},
"type": "RIGHT_EAR_TRAGION"
},
{
"position": {
"x": 350.22372,
"y": 100.80855,
"z": -8.056211
},
"type": "FOREHEAD_GLABELLA"
},
{
"position": {
"x": 350.92908,
"y": 189.51155,
"z": -14.014768
},
"type": "CHIN_GNATHION"
},
{
"position": {
"x": 304.9187,
"y": 170.83353,
"z": 27.585705
},
"type": "CHIN_LEFT_GONION"
},
{
"position": {
"x": 396.78854,
"y": 169.80559,
"z": 27.643484
},
"type": "CHIN_RIGHT_GONION"
}
],
"panAngle": -0.041533586,
"rollAngle": -0.4864438,
"sorrowLikelihood": "VERY_UNLIKELY",
"surpriseLikelihood": "VERY_LIKELY",
"tiltAngle": 9.323663,
"underExposedLikelihood": "VERY_UNLIKELY"
}
]
}
]
}
読み取れる感情としては以下の4つ
- angerLikelihood(怒り)
- sorrowLikelihood(悲しみ)
- joyLikelihood(楽しみ)
- surpriseLikelihood(驚き)
その他に
- underExposedLikelihood(露光度合い)
- blurredLikelihood(ぼやけ具合)
といった内容や
- headwearLikelihood(帽子を被っているか)
といったものまで解析できるようです。
また、その解析の確からしさが
- detectionConfidence
で数値化されています。
前回の戻り値のJSON($jsonArr)を使うと
echo $jsonArr["responses"][0]["faceAnnotations"][0]["angerLikelihood"]; echo $jsonArr["responses"][0]["faceAnnotations"][0]["detectionConfidence"];
といった記述で表示することができます。
次回は解析画像をアップロードする用のPHPプログラムを作成します。
初級インフラエンジニアにオススメ連載リンク
ネットワーク学習の登竜門・・
ゼロからのCCNA独学講座
Linuxの取り扱いを基礎から学ぶ
Linux資格 「LPIC-Lv1」徹底解説