GithubHelp home page GithubHelp logo

ryannkim327 / image-to-text Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 19.41 MB

A simple Tesseract wherein you can have the text from the image. Idea from: https://www.npmjs.com/package/text-from-image

Home Page: https://www.npmjs.com/package/pls-img-txt

License: MIT License

JavaScript 100.00%
image-to-image

image-to-text's Introduction

Image to Text

MPOP Reverse II

How to install

npm install pls-img-txt

How to use (scan) .scan(imagePath [, ocr_engine_mode] [, pageseg_mode])

The OCR (Optical Character Recognition) Engine Mode is one part of this project from its first release. According to IBM, Optical character recognition (OCR) is sometimes referred to as text recognition. An OCR program extracts and repurposes data from scanned documents, camera images and image-only pdfs. OCR software singles out letters on the image, puts them into words and then puts the words into sentences, thus enabling access to and editing of the original content. It also eliminates the need for manual data entry. The Page segmentation mode defines how your text should be treated by Tesseract. For example, if your image contains a single character or a block of text, you want to specify the corresponding psm so that you can improve accuracy. According to David Sixela. This two are now added as customized options in this project, it is still optional for developers to user with the default value of ocr_engine_mode = 2 and pageseg_mode = 3.

const { scan } = require("pls-img-txt")

let run = async () => {
	let output = await scan("./sampleimg.png")
	// await scan("./sampleimg.png", 2, 3)
	// This is just optional
	console.log(output)
}

run()

Result

{
	"result": "Sample text"
}

How to use (Add language) .addLanguage([language])

This feature is just optional, this package has already default installed languages which are english and the orientation and script detection (osd).

const pls_img_txt = require("pls-img-txt")

let run = async () => {
	pls_img_txt.addLanguage(pls_img_txt.CEBUANO)
	pls_img_txt.addLanguage(pls_img_txt.FILIPINO)
	pls_img_txt.addLanguage(pls_img_txt.TAGALOG)
	let output = await pls_img_txt.scan("./sampleimg.png")
	console.log(output)
}

run()

Add language is still in development, so that this feature might not be stable. Try to add some try catch to handle this kind of error and to avoid some crash on to your system.

Language Lists

  • ARABIC
  • CEBUANO
  • CHINESE_SIMPLIFIED
  • CHINESE_TRADITIONAL
  • GERMAN
  • GREEK
  • FILIPINO
  • HEBREW
  • JAPANESE
  • KOREAN
  • TAGALOG

For more language, kindly visit this link, and use the key language to add.


Credits

  1. Tesseract.js
  2. cli-progress
  3. ansi-colors

image-to-text's People

Contributors

ryannkim327 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.