Skip to content

A service that provides OCR capabilities using Tesseract. Built using Rust and the Axum web framework.

License

Notifications You must be signed in to change notification settings

seferino-fernandez/ocr_service

Repository files navigation

OCR Service

This repository contains OCR Service built using Axum.

The full list of crates used can be found in the Cargo.toml file. However, here are some key ones:

  • axum - A user-friendly, modular web framework built with Tokio, Tower, and Hyper.
  • tesseract-rs - A library for OCR using Tesseract Rust bindings.
  • image - An image processing library for Rust.
  • Insta - A library for snapshot testing in Rust.
  • utoipa - A library for generating OpenAPI documentation in Rust.
  • opentelemetry-rust - OpenTelemetry for Rust.

Getting Started

Configure the Application

Environment Variables

You can use the .env.example file or src/config/app_config.rs to view and configure the application.

Download Tesseract Data Files

The OCR Service requires the Tesseract data files to be downloaded into the tesseract directory. You can download the files manually via these repositories:

Or by running the scripts/download-tessdata.sh script.

Starting the Application

With everything else set up, all you need to do now is:

cargo run

Running Tests

Run tests:

cargo test

Run Snapshot tests:

cargo insta test

Run and review Snapshot tests:

cargo insta test --review

Linting and Formatting

Run Clippy:

cargo clippy

Run Rustfmt:

cargo fmt

Deployment

For building and running the docker image locally:

docker build -t ocr-service .
docker run -p 8080:8080 ocr-service

API Documentation

The API documentation is available at http://localhost:8080/api-docs when running locally.

curl Examples

Send a file to the /api/v1/images endpoint to process the image.

curl -X POST -F "image=@./tests/images/tessdoc-introduction.png" \
http://localhost:8080/api/v1/images

Health Check

curl http://localhost:8080/health

About

A service that provides OCR capabilities using Tesseract. Built using Rust and the Axum web framework.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published