Tesseract C++ API in Pure Javascript
npm install tesseract.js-coretesseract.js-core
=================

Core part of tesseract.js, which compiles original tesseract from C to JavaScript WebAssembly.
To build tesseract-core.js by yourself, please install docker and run:
```
bash build-with-docker.sh
The generated files will be stored in root path. When compiling, errors sometimes occur due to race conditions (some dependencies do not appear to compile properly in parallel). Re-running generally resolves.
1. Build scripts are in build-scripts folderjavascript
2. Javascript/wrapper files are in folderthird_party
3. All dependencies (including Tesseract) are in folderCMakeLists.txt
1. All dependencies are unmodified except for Tesseract, which uses a forked repo
1. The Tesseract repo has the following changes:
1. Modified to build with emscriptenltrresultiterator.h
1. Modified and ltrresultiterator.cpp to add WordChoiceIterator classsrc/arch_sse
1. Added folder, which is used instead of src/arch for the simd-enabled buildsrc/textord/colfind.cpp
1. This hard-codes the use of the SSE function
1. Commented out "Empty page!!" message in to prevent this from printing to consolesrc/ccmain/thresholder.cpp
1. Added functions for detecting page angle and applying rotation
1. Modified , src/ccmain/thresholder.h, src/api/baseapi.cpp, and include/tesseract/baseapi.h to add exif and angle arguments for rotating imagesFindLines
1. Changed from "protected" to "public" in baseapi.h to expose to JavascriptGetGradient
1. Allows for lines (and therefore page angle) to be detected without running unnecessary steps afterwards
1. Added public function to baseapi.h and baseapi.cpp for reporting page anglesrc/ccmain/tesseractclass.h
1. Also required minor changes to , src/ccmain/pagesegmain.cpp, src/textord/textord.cpp, and src/textord/textord.hWriteImage
1. See this commit: https://github.com/Balearica/tesseract/commit/db6951f655263878f6344380a5ddb95e678d7c09
2. Added function to baseapi.h and baseapi.cpp for saving images (original, grey, and binary)SaveParameters
3. Added and RestoreParameters functions to baseapi.h and baseapi.cpp for saving and restoring parametersEM_ASM_ARGS
4. Added calls to to src/ccmain/control.cpp for progress logging (and added header)tprintf
5. Rewrote function in src/ccutil/tprintf.cpp to force flushingSetImage
6. Added new version of to src/api/baseapi.cpp and include/tesseract/baseapi.h that reads image from filesystemParamUtils::PrintParams
1. This was done to resolve memory leak--see this issue
7. Edited in src/ccutil/params.cpp to remove description text (resolves bug)src/ccmain/tessedit.cpp
1. The bug was reported in this Git Issue, so we can cut this point if resolved in a future version of Tesseract
8. Edited to save error log to separate file (/debugDev.txt)src/api/jsonrenderer.cpp
1. Added JSON as an ouput format
1. Added , modified CMakeLists.txt, include/tesseract/baseapi.h, and include/tesseract/renderer.h
). Then navigate to the pages in examples/web/minimal/ in your browser. To run the node examples, navigate to
examples/node/minimal/ and then run e.g. node index.wasm.js [input_file].The "benchmark" examples behave similarly, except that they take longer to run and report runtime instead of recognition text. All other examples are experimental and should not be expected to run.
Contribution
As we leverage git-submodule to manage dependencies, remember to add recursive when cloning the repository:
`
git clone --recursive https://github.com/naptha/tesseract.js-core
``