Created
April 15, 2019 23:39
-
-
Save VeronicaM/5cb3b4e9a50b8be752fa96c6db3c48ac to your computer and use it in GitHub Desktop.
send image to google vision endpoint
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
// Get an image dataURL from the canvas. | |
var imageDataURL = hidden_canvas.toDataURL('image/png'); | |
var courseLang = document.querySelector('#courseLanguage').value; | |
return fetch(url, { | |
method: "POST", | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ img: imageDataURL, courseLang: courseLang }) | |
}).then(response => response.json()) | |
.then(response => { | |
const listLabels = response && response.map((word) => { | |
return `<div>${word.courseLang} ( ${word.text})</div>` | |
}).join(''); | |
labels.innerHTML = `<label><h2> You pointed at: </h2> </label> | |
<div class='words-list'>${listLabels}</div>`; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment