Skip to content

KevinBLT/text_detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Description

This library adds an abstraction above the original TextDetector object that will call it via a web worker internally. If the TextDetector is not available in the browser or the platform, a tensorflow version for OCR is used.

Example

Include the library lib/text_detector.js as a script, so that it runs before any code using TextDetector.

let textDetector  = new TextDetector();
let detectedTexts = await textDetector.detect(document.querySelector('img'));

for (let e of detectedTexts) {
  console.log(e.rawValue);
}

There are some additions to the original API.

See the following:

textDetector.minSize; // The min size used for images, scaled up   if needed
textDetector.maxSize; // The min size used for images, scaled down if exceeded

console.log(e.textLines);        // The text as a list of lines
console.log(e.fullText);         // The full decoded
console.log(e._decodeDuration);  // The duration of the decoding in ms
console.log(e._decoder);         // 'native' | 'tensorflow'

for (let e of detectedTexts) {
  console.log(e.angle); // The angle of the rect
}

Credits

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published