Code Monkey home page Code Monkey logo

dev-tesseract-nestjs's Introduction

Image Recognition using Tesseract in NestJS

Description

OCR (Optical character recognition) is a technology which scans images to recognize texts of them. Tesseract is a library of OCR engine which is a free and also have a nice recognition rate.

We develop an API in NestJS using tesseract.js which is a javascript version of Tesseract. The API contains an example usage of tesseract.js in language, Korean and English, via uploading image files to be recognized. Furthermore, we develop specific area recognition within 4-area (top-left, top-right, bottom-left, and bottom-right).

Dependency

npm install

Main dependencies are also commented in codes. We can use them.

Run

npm run start

Test

npm run test

We have some unit tests to experience OCR as examples.

Config

See tesseract.constant.ts.

How to use API with Postman

When we start the codes, NestJS server runs with port number 3000 in default. Now, we can POST to API.

Name Value
API http://localhost:3000/tesseract/upload
Method POST
Content-Type multipart/form-data

In Body, image files must be uploaded and options can be appended. Uploading image files without any options are recognized in all areas. If match KEY between of files and data, the data is used as an option.

Here is an example in body of uploading 2 image files.

Key Value Mandatory
book book.png Mandatory
book top-left Optional
code code.jpg Mandatory
code bottom-right Optional

Then, top-left of book.png and bottom-right of code.jpg are recognized, respectively.

Comment

If recognized results are ridiculous, you can doubt resizing of images. 'Resizing' can export incorrect results. It is recommended that you should check the images by adding an extension(.png) to the uploaded file in 'upload' directory.

Reference

[1] Github naptha/tesseract.js

[2] Github naphta/tesseract.js API

[3] OCR 라이브러리 Tesseract.js 사용해보기

dev-tesseract-nestjs's People

Contributors

hubts avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.