|
|
||
|---|---|---|
| .. | ||
| LICENSE | ||
| README.md | ||
| index.js | ||
| package.json | ||
| tesseract-core-lstm.js | ||
| tesseract-core-lstm.wasm | ||
| tesseract-core-lstm.wasm.js | ||
| tesseract-core-simd-lstm.js | ||
| tesseract-core-simd-lstm.wasm | ||
| tesseract-core-simd-lstm.wasm.js | ||
| tesseract-core-simd.js | ||
| tesseract-core-simd.wasm | ||
| tesseract-core-simd.wasm.js | ||
| tesseract-core.js | ||
| tesseract-core.wasm | ||
| tesseract-core.wasm.js | ||
README.md
tesseract.js-core
Core part of tesseract.js, which compiles original tesseract from C to JavaScript WebAssembly.
Compiling
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.
Structure
- Build scripts are in
build-scriptsfolder - Javascript/wrapper files are in
javascriptfolder - All dependencies (including Tesseract) are in
third_partyfolder- All dependencies are unmodified except for Tesseract, which uses a forked repo
- The Tesseract repo has the following changes:
- Modified
CMakeLists.txtto build with emscripten - Modified
ltrresultiterator.handltrresultiterator.cppto addWordChoiceIteratorclass - Added
src/arch_ssefolder, which is used instead ofsrc/archfor the simd-enabled build- This hard-codes the use of the SSE function
- Commented out "Empty page!!" message in
src/textord/colfind.cppto prevent this from printing to console - Added functions for detecting page angle and applying rotation
- Modified
src/ccmain/thresholder.cpp,src/ccmain/thresholder.h,src/api/baseapi.cpp, andinclude/tesseract/baseapi.hto addexifandanglearguments for rotating images - Changed
FindLinesfrom "protected" to "public" inbaseapi.hto expose to Javascript- Allows for lines (and therefore page angle) to be detected without running unnecessary steps afterwards
- Added public
GetGradientfunction tobaseapi.handbaseapi.cppfor reporting page angle- Also required minor changes to
src/ccmain/tesseractclass.h,src/ccmain/pagesegmain.cpp,src/textord/textord.cpp, andsrc/textord/textord.h- See this commit:
db6951f655
- See this commit:
- Also required minor changes to
- Modified
- Added
WriteImagefunction tobaseapi.handbaseapi.cppfor saving images (original, grey, and binary) - Added
SaveParametersandRestoreParametersfunctions tobaseapi.handbaseapi.cppfor saving and restoring parameters - Added calls to
EM_ASM_ARGStosrc/ccmain/control.cppfor progress logging (and added<emscripten.h>header) - Rewrote
tprintffunction insrc/ccutil/tprintf.cppto force flushing - Added new version of
SetImagetosrc/api/baseapi.cppandinclude/tesseract/baseapi.hthat reads image from filesystem- This was done to resolve memory leak--see this issue
- Edited
ParamUtils::PrintParamsinsrc/ccutil/params.cppto remove description text (resolves bug)- The bug was reported in this Git Issue, so we can cut this point if resolved in a future version of Tesseract
- Edited
src/ccmain/tessedit.cppto save error log to separate file (/debugDev.txt) - Added JSON as an ouput format
- Added
src/api/jsonrenderer.cpp, modifiedCMakeLists.txt,include/tesseract/baseapi.h, andinclude/tesseract/renderer.h
- Added
- Modified
Running Minimal Examples
To run the browser examples, launch a web server in the root of the repo (i.e. run http-server). 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
