Simple node/express app to demonstrate OCR
Drag and drop a picture onto a webpage and see the extracted text
To check if you have node already installed, run this command in your terminal:
$ node -v
NPM comes included with Node, but to confrim you have npm installed, you can run this command in your terminal:
$ npm -v
If you do not have Node, you can either:
Get an API subcription key and base uri from Microsoft's Computer Vision API
- You will be adding the subscription key and base uri to the
config.js
file in the project - We will be using only the 'Read text in images' or OCR functionality
Follow these instructions for a simple Node proof of concept (not a web app/no Express)
- Copy the
v1-ocr.js
file - Change the strings for
subscriptionKey
,uriBase
from your Microsoft API - Change the
imageUrl
to the image you would like analyzed - run
node v1-ocr.js
in your terminal
- Copy the
v2-ocr.js
file - Change the strings for
subscriptionKey
,uriBase
from your Microsoft API - Change the argument to
readFileSync
forimage_file
using a valid path to a local image - run
node v2-ocr.js
in your terminal
- Clone the repository
- Make an
uploads/
directory at the root of the project and make sure it's writeable - Run npm install
- Update the configs in
config.js
- use dotenv to load enviroment variables from .env into your node.js app
- Run the app with
node app.js
- The app will run on port 3000 (localhost:3000)
- Node - Javascript runtime
- Express - Node.js web app framework
- Microsoft OCR API - for image to text API
- Dropzone.js - drag & drop file uploads
- Pug - HTML templating engine
- Jinoo Jain - Nightingale Security