Build A Javascript OCR App Tutorial




Check out my courses and become more creative!
https://developedbyed.com/

🎁Support me on Patreon for exclusive episodes, discord and more!
https://www.patreon.com/dev_ed

Today we are building a new exciting javascript project!
We will be using OCR (optical character recognition) to recognize an image and extract all the text from it.

We will be using a few packages such as express, multer and tesseract.js. At the end we will convert our image into a pdf.

If you feel like you need more practice with node.js or you just want some project ideas I highly recommend you to follow this tutorial!

🛴 Follow me on:
Twitch: https://www.twitch.tv/developedbyed
Twitter: https://twitter.com/developedbyed
Instagram: https://www.instagram.com/developedbyed/
Github: https://github.com/developedbyed/

#javascript #ocr

Original source


35 responses to “Build A Javascript OCR App Tutorial”

  1. For anyone who is still struggling with 'const worker = new TesseractWorker()' is not a constructor. Just do everything exactly as shown in the video.

    Just use npm install tesseract.js@2.0.0-alpha.15 to use the exact same version of tesseract as used in the video.
    Not sure if this is necessary but make sure you have "tesseract.js": "^2.0.0-alpha.15" mentioned as a dependency in your JSON file.
    *

    const {TesseractWorker} = require('tesseract.js')
    const worker = new TesseractWorker();

  2. For anyone still struggling with 'const worker = new TesseractWorker()' is not a constructor. TeseractWorker is depreciated in versions 2+ so we use createWorker() instead.
    Here is the fix:

    Replace all forms of TesseractWorker with createWorker() for versions 2.0+ of Tesseract by using npm install tesseract.js@next and npm install tesseract.js-core

    Install tesseract.js-core link: https://www.npmjs.com/package/tesseract.js-core

    Make sure to remove ^ the carrot sign before tesseract.js within the package.json which forces the dependency to be the newest version. Not sure if this step matters but the code below is what you use instead of TesseractWorker() which is depreciated in the 2.0+ versions.

    SOLUTION:
    const { createWorker } = require("tesseract.js");
    const worker = new createWorker({
    logger: m => console.log(m)
    });
    … rest of backend code in app.js

  3. Anyone getting the tesseract error:
    Fix below:
    (Also maybe someone smarter than me can clean this up a bit)

    https://github.com/naptha/tesseract.js/issues/346
    I'm on mobile so no correct syntax but
    Changing to "tesseract.js" : "2.0.0.alpha.13",
    And
    tesseract-js-core : 2.0.0-beta.11

    ^ Add those to package.json
    Plain `npm install` for dependant

    Remove any *"^"*'s from tesseract and tesseract-core in the `package.json` so it takes both versions (I think that's how you do it? Someone smarter than me can correct:) )

    Changing those in package.json seemed to get the app working.

    Ily

  4. My terminal:

    $ : The term '$' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of t

    he name, or if a path was included, verify that the path is correct and try again.

    At line:1 char:1

    + $ npm install ejs express multer tesseract.js

    + ~

    + CategoryInfo : ObjectNotFound: ($:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException

  5. Your videos are good but for beginners it's like copying the code because you don't describe code clearly line by line.
    and if you could please watch the some of the videos of "the net ninja" the line by line explanation he provides is way better than you .
    just a suggestion so that you can make your content more better. Thank-You

Leave a Reply