Command for converting image to base64 and to access the Google Cloud Vision API from terminal to detect emotion in a given photo. A sample request fils is also given below.
#command to convert jpeg to base64 encoding and copy to clipboard
base64 safwan.jpg | pbcopy
#command to access the google api from terminal.
#Replace the [API-Key] with your key & request.json with your request file.
curl -v -k -s -H "Content-Type: application/json" https://vision.googleapis.com/v1/images:annotate?key=[API-Key] --data-binary @request.json {
"requests":[
{
"image":{
"content": "[ BASE 64 IMAGE ]"
},
"features": [
{
"type":"FACE_DETECTION",
"maxResults":1
}
]
}
]
}