Created
February 21, 2019 07:33
-
-
Save alfredayibonte/5d23e13d600ff0c2487f8f0a2129131b to your computer and use it in GitHub Desktop.
OCR
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 URL = `https://vision.googleapis.com/v1/images:annotate?key=${Config.GOOGLE_VISION_API_KEY}`; | |
export function ocr(base64) { | |
const request = { | |
requests: [ | |
{ | |
image: { | |
content: base64 | |
}, | |
features: [ | |
{ | |
type: 'TEXT_DETECTION', | |
maxResults: 200 | |
} | |
] | |
} | |
] | |
}; | |
return new Promise(function(resolve, reject) { | |
fetch(URL, { | |
method: 'POST', | |
headers: ['Content-Type', 'application/json'], | |
body: JSON.stringify(request) | |
}) | |
.then(data => { | |
resolve(getText(data)) | |
}) | |
.catch(err => { | |
reject(err) | |
}); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment