JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q47794F
  • License MIT

Upload a picture of a mathemetical simples equations (letter and numbers only). Get OCR result back.

Package Exports

  • tesseract-wrapper

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tesseract-wrapper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tesseract-wrapper

Simple module for executing tesseract command to read a base64 image file.

Build Status npm (scoped) npm

PLEASE NOTE

This module is open for public usage, but I have developed it solely for creating an API endpoint on a private VPS. It has a hard dependency of tesseract. You need to have it compiled and its CLI working to use this module. Please read this to help you compile from source or you could use this to try and install it via PPA.

Installation and usage:

$ npm install tesseract-wrapper

then

var tesseract_wrapper = require('tesseract-wrapper')

or (ES6)

import { tesseract-wrapper } from 'tesseract-wrapper'

The API structure

It has a simple method that takes an object with the base64 image data and the langague that tesseract should OCR to

Methods

  • execTesseract: OCRs the base64 image in the language specified in the options parameter

execTesseract

Function to execute tesseract command with the right parameters.

The tasks:

  • 1 - Write image file
  • 2 - Get file path
  • 3 - Exec tesseract
  • 4 - Read outputFile
  • 5 - Delete tempFile
  • 6 - Delete outputFile
  • 7 - Return result object in promise
var tesseract_wrapper = require('tesseract-wrapper');

var options = {
  data: Base64String,
  lang: 'eng'
}

tesseract_wrapper
  .execTesseract(options)
  .then(result => console.log(result))
  .catch(err => console.log(err))

The log would be:

  { fileContent: '2x" -7x +3 = 0\n(2x -1) (x -3)= 0\n\n' }

How to test it?

To run all unit testing simply do:

npm test