Notes sur l'écriture de votre propre code basé sur Documents officiels
Installez les packages requis pour le moment. Vous pouvez le faire avec des requêtes etc., mais projectoxford est plus facile à écrire, alors j'ai adopté ça!
$ pip install projectoxford
Après cela, préparez une clé d'abonnement et une image, et écrivez un programme.
face_api.py
import json, requests
from projectoxford import Client
client = Client('<your_subscription_key>')
res = {
"url": "<image_url>",
# or
#'path': '</local/path/to/your_image>',
'analyzesFaceLandmarks': True,
'analyzesAge': True,
'analyzesGender': True,
'analyzesHeadPose': True,
}
result = client.face.detect(res)
print json.dumps(result, indent=4)
#Outre détecter, tâtonner, identify, verify,similaire etc.
Au fait, le résultat est comme ça.
$ python face_api.py
[
{
"attributes": {
"gender": "male",
"age": 35,
"headPose": {
"yaw": -7.7,
"roll": -5.7,
"pitch": 0.0
}
},
"faceId": "************************",
"faceRectangle": {
"width": 99,
"top": 80,
"height": 99,
"left": 201
},
"faceLandmarks": {
"underLipTop": {
"y": 160.5,
"x": 250.2
},
"noseTip": {
"y": 129.7,
"x": 247.1
},
"upperLipBottom": {
"y": 149.8,
"x": 249.5
},
"noseLeftAlarTop": {
"y": 124.6,
"x": 240.2
},
"eyebrowLeftOuter": {
"y": 107.8,
"x": 208.7
},
"eyeLeftBottom": {
"y": 112.8,
"x": 226.7
},
"pupilLeft": {
"y": 110.1,
"x": 228.2
},
"upperLipTop": {
"y": 145.1,
"x": 249.1
},
"eyeLeftInner": {
"y": 110.3,
"x": 234.0
},
"eyeRightInner": {
"y": 107.0,
"x": 262.8
},
"eyeLeftTop": {
"y": 108.5,
"x": 227.0
},
"mouthLeft": {
"y": 155.5,
"x": 233.0
},
"noseRightAlarTop": {
"y": 122.7,
"x": 258.3
},
"eyebrowRightInner": {
"y": 101.1,
"x": 253.9
},
"noseLeftAlarOutTip": {
"y": 133.7,
"x": 234.8
},
"noseRightAlarOutTip": {
"y": 130.4,
"x": 263.9
},
"noseRootRight": {
"y": 109.6,
"x": 253.9
},
"eyeLeftOuter": {
"y": 112.4,
"x": 219.9
},
"underLipBottom": {
"y": 166.9,
"x": 251.3
},
"eyeRightTop": {
"y": 102.8,
"x": 269.8
},
"eyeRightOuter": {
"y": 105.1,
"x": 276.1
},
"noseRootLeft": {
"y": 110.9,
"x": 240.6
},
"eyebrowRightOuter": {
"y": 96.1,
"x": 286.1
},
"eyeRightBottom": {
"y": 107.0,
"x": 270.2
},
"eyebrowLeftInner": {
"y": 104.1,
"x": 234.6
},
"mouthRight": {
"y": 150.6,
"x": 272.5
},
"pupilRight": {
"y": 104.4,
"x": 270.5
}
}
}
]
Recommended Posts