Skip to content

Instantly share code, notes, and snippets.

@dtkloud
Last active September 7, 2016 06:17
Show Gist options
  • Save dtkloud/2c58859008fb7b946957618cdcc0b367 to your computer and use it in GitHub Desktop.
Save dtkloud/2c58859008fb7b946957618cdcc0b367 to your computer and use it in GitHub Desktop.
$subkey_CV = 'yourCVAPIKey'
$subkey_Face = 'yourFaceAPIKey'
$filepath = 'C:\temp\Framing_Test.jpg'
$Splat_CV = @{
Uri= "https://api.projectoxford.ai/vision/v1.0/analyze"
Method = 'Post'
InFile = $filepath
ContentType = 'application/octet-stream'
Headers = @{'Ocp-Apim-Subscription-Key' = $subkey_CV}
}
$Splat_Face = @{
Uri= "https://api.projectoxford.ai/face/v1.0/detect"
Method = 'Post'
InFile = $filepath
ContentType = 'application/octet-stream'
Headers = @{'Ocp-Apim-Subscription-Key' = $subkey_Face}
}
$imgwidth = (Invoke-RestMethod @Splat_CV).metadata.width
$FaceRectangleWidth = (Invoke-RestMethod @Splat_Face).faceRectangle.width
$PercentageofFace = $FaceRectangleWidth * (100 / $imgwidth)
if (($PercentageofFace -gt 35) -and ($PercentageofFace -lt 65))
{
$GoodFraming = $True
}
if (($PercentageofFace -lt 35) -or ($PercentageofFace -gt 65))
{
$GoodFraming = $False
}
$GoodFraming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment