Browse Source

Merge pull request #288 from HoldYourWaffle/patch-1

Improved README
pull/290/head
jeromewu 6 years ago committed by GitHub
parent
commit
1e8ea8f465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 118
      README.md

118
README.md

@ -1,80 +1,80 @@
# [Tesseract.js](http://tesseract.projectnaptha.com/) [![Tesseract.js](https://tesseract.projectnaptha.com/img/logowhite.png)](https://tesseract.projectnaptha.com/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Code Style](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/naptha/tesseract.js/graphs/commit-activity)
[![Build Status](https://travis-ci.org/naptha/tesseract.js.svg?branch=master)](https://travis-ci.org/naptha/tesseract.js) [![Build Status](https://travis-ci.org/naptha/tesseract.js.svg?branch=master)](https://travis-ci.org/naptha/tesseract.js)
[![npm version](https://badge.fury.io/js/tesseract.js.svg)](https://badge.fury.io/js/tesseract.js) [![npm version](https://badge.fury.io/js/tesseract.js.svg)](https://badge.fury.io/js/tesseract.js)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/naptha/tesseract.js/graphs/commit-activity)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Code Style](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)
[![Downloads Total](https://img.shields.io/npm/dt/tesseract.js.svg)](https://www.npmjs.com/package/tesseract.js) [![Downloads Total](https://img.shields.io/npm/dt/tesseract.js.svg)](https://www.npmjs.com/package/tesseract.js)
[![Downloads Month](https://img.shields.io/npm/dm/tesseract.js.svg)](https://www.npmjs.com/package/tesseract.js) [![Downloads Month](https://img.shields.io/npm/dm/tesseract.js.svg)](https://www.npmjs.com/package/tesseract.js)
**Tesseract.js v2 is now available and under development in master branch, check [support/1.x](https://github.com/naptha/tesseract.js/tree/support/1.x) branch for v1.** <h3 align="center">
Version 2 is now available and under development in the master branch<br>
Check the <a href="https://github.com/naptha/tesseract.js/tree/support/1.x">support/1.x</a> branch for version 1
</h3>
<br>
Tesseract.js is a javascript library that gets words in [almost any language](./docs/tesseract_lang_list.md) out of images. ([Demo](http://tesseract.projectnaptha.com/)) Tesseract.js is a javascript library that gets words in [almost any language](./docs/tesseract_lang_list.md) out of images. ([Demo](http://tesseract.projectnaptha.com/))
[![fancy demo gif](./docs/images/demo.gif)](http://tesseract.projectnaptha.com) [![fancy demo gif](./docs/images/demo.gif)](http://tesseract.projectnaptha.com)
Tesseract.js works with script tags, [webpack](https://webpack.js.org/), and [Node.js](https://nodejs.org/en/). [After you install it](#installation), using it is as simple as Tesseract.js wraps an [emscripten](https://github.com/kripken/emscripten) [port](https://github.com/naptha/tesseract.js-core) of the [Tesseract](https://github.com/tesseract-ocr/tesseract) [OCR](https://en.wikipedia.org/wiki/Optical_character_recognition) Engine.
It works in the browser using [webpack](https://webpack.js.org/) or plain script tags with a [#CDN](CDN) and on the server with [Node.js](https://nodejs.org/en/).
After you [install it](#installation), using it is as simple as:
```javascript ```javascript
import { TesseractWorker } from 'tesseract.js'; import { TesseractWorker } from 'tesseract.js';
const worker = new TesseractWorker(); const worker = new TesseractWorker();
worker.recognize(myImage) worker.recognize(myImage)
.progress((p) => { console.log('progress', p); }) .progress(progress => {
.then((result) => { console.log('result', result); }); console.log('progress', progress);
}).then(result => {
console.log('result', result);
});
``` ```
[Check out the docs](#docs) for a full treatment of the API. [Check out the docs](#docs) for a full explanation of the API.
## Provenance
Tesseract.js wraps an [emscripten](https://github.com/kripken/emscripten) [port](https://github.com/naptha/tesseract.js-core) of the [Tesseract](https://github.com/tesseract-ocr/tesseract) [OCR](https://en.wikipedia.org/wiki/Optical_character_recognition) Engine.
## Major changes in v2
- Upgrade to tesseract v4
- Support multiple languages at the same time, eg: eng+chi_tra for English and Traditional Chinese
- Supported image formats: png, jpg, bmp, pbm
# Installation
Tesseract.js works with a `<script>` tag via local copy or CDN, with webpack via `npm`, and on Node.js via `npm`. [Check out the docs](#docs) for a full treatment of the API.
## CDN ## Installation
Tesseract.js works with a `<script>` tag via local copy or CDN, with webpack via `npm` and on Node.js with `npm/yarn`.
You can simply include Tesseract.js with a CDN like this:
### CDN
```html ```html
<!-- v2 -->
<script src='https://unpkg.com/tesseract.js@v2.0.0-alpha.10/dist/tesseract.min.js'></script> <script src='https://unpkg.com/tesseract.js@v2.0.0-alpha.10/dist/tesseract.min.js'></script>
```
After including your scripts, the `Tesseract` variable will be defined globally!
## npm <!-- v1 -->
<script src='https://unpkg.com/tesseract.js@1.0.19/src/index.js'></script>
```
After including the script the `Tesseract` variable will be globally available.
### 2.x
Major Changes ### Node.js
- Upgrade to tesseract v4 **Tesseract.js currently requires Node.js v6.8.0 or higher**
- Support multiple languages, ex: eng+chi_tra
- Support image formats: png, jpg, bmp, pbm
```shell ```shell
> yarn add tesseract.js@next # For v2
``` npm install tesseract.js@next
or yarn add tesseract.js@next
```
> npm install tesseract.js@next --save
```
### 1.x
```shell # For v1
> yarn add tesseract.js npm install tesseract.js
``` yarn add tesseract.js
or
```
> npm install tesseract.js --save
``` ```
> Note: Tesseract.js currently requires Node.js v6.8.0 or higher.
# Documentation ## Documentation
* [Examples](./docs/examples.md) * [Examples](./docs/examples.md)
* [Image Format](./docs/image-format.md) * [Image Format](./docs/image-format.md)
@ -82,33 +82,29 @@ or
* [Local Installation](./docs/local-installation.md) * [Local Installation](./docs/local-installation.md)
* [FAQ](./docs/faq.md) * [FAQ](./docs/faq.md)
# Contributing
## Development ## Contributing
To run a development copy of tesseract.js, first clone this repo.
```shell
> git clone https://github.com/naptha/tesseract.js.git
```
Then, `cd tesseract.js && npm install && npm start` ### Development
To run a development copy of Tesseract.js do the following:
```shell ```shell
> cd tesseract.js # First we clone the repository
> npm install && npm start git clone https://github.com/naptha/tesseract.js.git
cd tesseract.js
... a bunch of npm stuff ...
Starting up http-server, serving ./ # Then we install the dependencies
Available on: npm install
http://127.0.0.1:3000
http://[your ip]:3000
# And finally we start the development server
npm start
``` ```
Then open `http://localhost:3000/examples/browser/demo.html` in your favorite browser. The devServer automatically rebuilds `tesseract.dev.js` and `worker.min.js` when you change files in the src folder. The development server will be available at http://localhost:3000/examples/browser/demo.html in your favorite browser.
It will automatically rebuild `tesseract.dev.js` and `worker.min.js` when you change files in the src folder.
## Building Static Files
After you've cloned the repo and run `npm install` as described in the [Development Section](#development), you can build static library files in the dist folder with
### Building Static Files
To build the compiled static files just execute the following:
```shell ```shell
> npm run build npm run build
``` ```
This will output the files into the `dist` directory.

Loading…
Cancel
Save