npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tesseract.js-core

v5.1.1

Published

Tesseract C++ API in Pure Javascript

Downloads

536,149

Readme

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

  1. Build scripts are in build-scripts folder
  2. Javascript/wrapper files are in javascript folder
  3. All dependencies (including Tesseract) are in third_party folder
    1. All dependencies are unmodified except for Tesseract, which uses a forked repo
    2. The Tesseract repo has the following changes:
      1. Modified CMakeLists.txt to build with emscripten
      2. Modified ltrresultiterator.h and ltrresultiterator.cpp to add WordChoiceIterator class
      3. Added src/arch_see folder, which is used instead of src/arch for the simd-enabled build
        1. This hard-codes the use of the SSE function
      4. Commented out "Empty page!!" message in src/textord/colfind.cpp to prevent this from printing to console
      5. Added functions for detecting page angle and applying rotation
        1. Modified src/ccmain/thresholder.cpp, src/ccmain/thresholder.h, src/api/baseapi.cpp, and include/tesseract/baseapi.h to add exif and angle arguments for rotating images
        2. Changed FindLines from "protected" to "public" in baseapi.h to expose to Javascript
          1. Allows for lines (and therefore page angle) to be detected without running unnecessary steps afterwards
        3. Added public GetGradient function to baseapi.h and baseapi.cpp for reporting page angle
          1. Also required minor changes to src/ccmain/tesseractclass.h, src/ccmain/pagesegmain.cpp, src/textord/textord.cpp, and src/textord/textord.h
            1. See this commit: https://github.com/Balearica/tesseract/commit/db6951f655263878f6344380a5ddb95e678d7c09
      6. Added WriteImage function to baseapi.h and baseapi.cpp for saving images (original, grey, and binary)
      7. Added SaveParameters and RestoreParameters functions to baseapi.h and baseapi.cpp for saving and restoring parameters
      8. Added calls to EM_ASM_ARGS to src/ccmain/control.cpp for progress logging (and added <emscripten.h> header)
      9. Rewrote tprintf function in src/ccutil/tprintf.cpp to force flushing
      10. Added new version of SetImage to src/api/baseapi.cpp and include/tesseract/baseapi.h that reads image from filesystem
        1. This was done to resolve memory leak--see this issue
      11. Edited ParamUtils::PrintParams in src/ccutil/params.cpp to remove description text (resolves bug)
        1. The bug was reported in this Git Issue, so we can cut this point if resolved in a future version of Tesseract
      12. Edited src/ccmain/tessedit.cpp to save error log to separate file (/debugDev.txt)

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