Created
May 22, 2017 14:16
-
-
Save deanhume/f0ac798ccfd6e3b44a6beb04d2b7f422 to your computer and use it in GitHub Desktop.
Text Detection - Shape Detection API
This file contains hidden or 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
var image = document.getElementById('image'); | |
// Does the current browser support the text detection API? | |
if (window.TextDetector) { | |
let textDetector = new TextDetector(); | |
textDetector.detect(theImage) | |
.then(detectedTextBlocks => { | |
// Loop through the results | |
for (const textBlock of detectedTextBlocks) { | |
console.log( | |
'text @ (${textBlock.boundingBox.x}, ${textBlock.boundingBox.y}), ' + | |
'size ${textBlock.boundingBox.width}x${textBlock.boundingBox.height}'); | |
} | |
}).catch(() => { | |
console.error("Text Detection failed, boo."); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment