Skip to content

Instantly share code, notes, and snippets.

@tylernappy
Last active August 23, 2016 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylernappy/06f8854ce9feb33191708688db1d1f17 to your computer and use it in GitHub Desktop.
Save tylernappy/06f8854ce9feb33191708688db1d1f17 to your computer and use it in GitHub Desktop.
Extract text from an image (OCR - optical character recognition) using Node.js
// install the official Haven OnDemand Node.js wrapper: https://github.com/HPE-Haven-OnDemand/havenondemand-node
// npm install --save havenondemand
var havenondemand = require('havenondemand')
var client = new havenondemand.HODClient('APIKEY')
// var data = {file: '/path/to/file.jpg', mode: 'document_photo', languages: ['en']} // uncomment if using a local file
var data = {url: 'https://www.havenondemand.com/sample-content/images/bowers.jpg', mode: 'document_photo', languages: ['en']} // uncomment if using a URL
client.post('ocrdocument', data, function(err, resp, body) {
var result = resp.body.text_block[0]
console.log(result)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment