Last active
November 9, 2018 08:32
-
-
Save Rinatamu/4b4650f9f4efa2b0afde5238b14d91b9 to your computer and use it in GitHub Desktop.
PowerShell で FaceAPI に投げてみる ref: https://qiita.com/rnakamuramartiny/items/48af81533a05e0817914
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Face_API_KEY = '<FaceAPI Key>' | |
$URL = 'https://japaneast.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=true&returnFaceAttributes=age,gender,smile,facialHair,headPose,glasses,emotion,hair,makeup,accessories,blur,exposure,noise' | |
$image = '<FaceAPIに投げるファイルのフルパス>' | |
$headers = @{ | |
'Ocp-Apim-Subscription-Key' = $Face_API_KEY | |
'Accept' = 'application/json' | |
'Content-Type' = 'application/octet-stream' | |
} | |
$result = Invoke-RestMethod ` | |
-Uri $URL ` | |
-Method Post ` | |
-Headers $headers ` | |
-InFile $image | |
$result_ps = ($result | ConvertFrom-Json) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
faceId : | |
faceRectangle : @{top=337; left=746; width=318; height=318} | |
faceLandmarks : @{pupilLeft=; pupilRight=; noseTip=; mouthLeft=; mouthRight=; eyebrowLeftOuter=; eyebrowLeftInner=; ey | |
eLeftOuter=; eyeLeftTop=; eyeLeftBottom=; eyeLeftInner=; eyebrowRightInner=; eyebrowRightOuter=; eyeRi | |
ghtInner=; eyeRightTop=; eyeRightBottom=; eyeRightOuter=; noseRootLeft=; noseRootRight=; noseLeftAlarT | |
op=; noseRightAlarTop=; noseLeftAlarOutTip=; noseRightAlarOutTip=; upperLipTop=; upperLipBottom=; unde | |
rLipTop=; underLipBottom=} | |
faceAttributes : @{smile=0.743; headPose=; gender=female; age=21.0; facialHair=; glasses=NoGlasses; emotion=; blur=; ex | |
posure=; noise=; makeup=; accessories=System.Object[]; hair=} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
($result_ps.faceAttributes.hair.hairColor | ` | |
Sort-Object -Property confidence -Descending | ` | |
Select-Object -First 1).Color |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment