3 ms·
The HTTP API is relatively simple to work with actually. Here is a quick example on how to work with it in NodeJS: var request = require('request')
by diggan 11y ago
The HTTP API is relatively simple to work with actually. Here is a quick example on how to work with it in NodeJS:
var request = require('request')
var file = require('fs').readFileSync('./testimage.png').toString('base64')
var body = {
requests: {
image: {
content: file
},
features: [
{
type: 'TEXT_DETECTION',
maxResults: 10
}
]
}
}
var url = 'https://vision.googleapis.com/v1/images:annotate\?key\=your_api_key'
request({
url: url,
method: 'POST',
body: JSON.stringify(body)
}, (err, res, body) => {
console.log(err)
console.log(body)
console.log(JSON.parse(body).responses[0].textAnnotations[0].description)
})
Basically you want to convert image data into base64, put it in the requests.image.content field and make a POST request and you'll get back the text.