text-recognition
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Text Recognition

What this package is about?

This package implements basic OCR logic which recognises and highlights text on image.

Installation

$ npm install text-recognition

...or using yarn:

$ yarn add text-recognition

Usage

const ocr = new Ocr({languages: ['eng', 'ukr']});

// add a callback for word selection and copying formatted text (should be done once on first render)
ocr.addSelectionListener();
// add progress listener to see the progress of OCR
ocr.addProgressListener(e => console.log(e));
// parsing image and processing OCR
await ocr.parseImage(image);
// appends generated HTML to the container
// 0.7 it's the scale of the container compared to the original image size.
await ocr.appendHtml(container, 0.7);

List of available language you can find here

While unmounting don't forget to remove listeners

ocr.removeSelectionListener();

Styling

Import SelectableElement.css to your project or add custom styles:

.text-recognition-word {
    color: transparent;
    opacity: .5;
}

.text-recognition-word::selection {
    background: transparent;
}

Readme

Keywords

none

Package Sidebar

Install

npm i text-recognition

Weekly Downloads

13

Version

1.0.4

License

ISC

Unpacked Size

29.6 kB

Total Files

10

Last publish

Collaborators

  • artelogic