Last active
November 17, 2018 22:02
-
-
Save ryqndev/df55b8a85b56de2d55d6c6c2d62f4130 to your computer and use it in GitHub Desktop.
Google Cloud Platform Text Recognition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// const GCPAPIKEY = 'Enter your key here'; | |
// const IMAGEURL = 'https://images-na.ssl-images-amazon.com/images/I/816C3tZ76IL.jpg' | |
function getTextFromGCP(GCPAPIKEY, IMAGEURL){ | |
var data = ` | |
{ | |
"requests": [ | |
{ | |
"image": { | |
"source": { | |
"imageUri": "${IMAGEURL}" | |
} | |
}, | |
"features": [ | |
{ | |
"type": "TEXT_DETECTION" | |
} | |
] | |
} | |
] | |
} | |
`; | |
var xhr = new XMLHttpRequest(); | |
xhr.addEventListener("readystatechange", function () { | |
if (this.readyState === 4) { | |
console.log(this.responseText); | |
} | |
}); | |
xhr.open("POST", `https://vision.googleapis.com/v1/images:annotate?key=${GCPAPIKEY}`); | |
xhr.send(data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment