************************
20170828_comp_exec.php
************************
‘;
echo $fullPath;
echo ‘
‘;
// is_array関数で配列かどうか判定する
if(is_array($outpara)) {
// 配列だったらforeach関数でループ処理
foreach ($outpara as $resout) {
if (strstr($resout, ‘faceId’)) {
echo ‘
‘;
echo “(file 1’s faceId is : ) “;
echo $resout;
//$ange=$resout;
//$a=$ange;
//$b=strpos($a,”:”);
//$c=strpos($a,’,’);
//$ange1=substr($a,$b+1,$c-$b-1);
//echo $ange1;
echo ‘
‘;
}
//print(‘
‘);
}
echo “X———————-“;
echo $resout;
// }
// 配列じゃなかったらエラーメッセージを表示
} else {
echo ‘ありません。’;
}
?>
************************
20170829_pho_verify.py
************************
import httplib, urllib, base64, json
import sys
args = sys.argv
###############################################
#### Update or verify the following values. ###
###############################################
# Replace the subscription_key string value with your valid subscription key.
subscription_key = ’13hc777******************72a8df7156′
# Replace or verify the region.
#
# You must use the same region in your REST API call as you used to obtain your subscription keys.
# For example, if you obtained your subscription keys from the westus region, replace
# “westcentralus” in the URI below with “westus”.
#
# NOTE: Free trial subscription keys are generated in the westcentralus region, so if you are using
# a free trial subscription key, you should not need to change this region.
uri_base = ‘westcentralus.api.cognitive.microsoft.com’
# Request headers.
headers = {
‘Content-Type’: ‘application/json’,
‘Ocp-Apim-Subscription-Key’: ‘91723******************d8ba36914b9’,
}
# Request parameters.
params = urllib.urlencode({
‘returnFaceId’: ‘true’,
‘returnFaceLandmarks’: ‘false’,
‘returnFaceAttributes’: ‘age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise’,
})
# The URL of a JPEG image to analyze.
# body = “{‘url’:’http://153.126.******************/20110826oresama.JPG’}”
##20170806 amend parts
body = “{‘url’:’http://153.126.******************/files/”+args[1]+”‘}”
######################
try:
# Execute the REST API call and get the response.
conn = httplib.HTTPSConnection(‘westcentralus.api.cognitive.microsoft.com’)
conn.request(“POST”, “/face/v1.0/detect?%s” % params, body, headers)
response = conn.getresponse()
data = response.read()
# ‘data’ contains the JSON data. The following formats the JSON data for display.
parsed = json.loads(data)
print (“Response:”)
print (json.dumps(parsed, sort_keys=True, indent=2))
conn.close()
except Exception as e:
print(“[Errno {0}] {1}”.format(e.errno, e.strerror))