Skip to content

Instantly share code, notes, and snippets.

@abeisgoat
Created February 27, 2016 11:33
Show Gist options
  • Save abeisgoat/efe683b46afd2d1bfdaf to your computer and use it in GitHub Desktop.
Save abeisgoat/efe683b46afd2d1bfdaf to your computer and use it in GitHub Desktop.
Google Vision Shell Script
#!/usr/bin/env bash
####################################################
## Google Vision API Client ##
####################################################
#
# 1. Create "key" file with GCloud credential
# 2. run ./annotate.sh URL
# 3. Get back Vision API tags
#
####################################################
echo "Prepping..."
REQUEST='{"requests":[{"image":{"content":"BASE64"},"features":[{"type":"LABEL_DETECTION","maxResults":5}]}]}'
BASE64_IMAGE=$(curl $1 | base64 -)
KEY=$(cat key)
echo "Alright, calling da googs..."
echo ${REQUEST/BASE64/$BASE64_IMAGE} | curl -k -s -H "Content-Type: application/json" https://vision.googleapis.com/v1/images:annotate?key=$KEY --data-binary @-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment