GithubHelp home page GithubHelp logo

pragmaticed / rtesseract Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dannnylo/rtesseract

0.0 2.0 0.0 1.35 MB

Ruby library for working with the Tesseract OCR.

Home Page: http://rubygems.org/gems/rtesseract

License: MIT License

Ruby 98.93% Shell 1.07%

rtesseract's Introduction

RTesseract

Gem Version Build Status Coverage Status

Ruby library for working with the Tesseract OCR.

Installation

Check if tesseract ocr programs is installed:

$ tesseract --version

Add this line to your application's Gemfile:

gem 'rtesseract'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rtesseract

Usage

It's very simple to use rtesseract.

Convert image to string

  image = RTesseract.new("my_image.jpg")
  image.to_s # Getting the value

Convert image to searchable PDF

  image = RTesseract.new("my_image.jpg")
  image.to_pdf  # Getting open file of pdf

Convert image to TSV

  image = RTesseract.new("my_image.jpg")
  image.to_tsv  # Getting open file of tsv

This will preserve the image colors, pictures and structure in the generated pdf.

Options

Language

    RTesseract.new('test.jpg', lang: 'deu')
  • eng - English
  • deu - German
  • deu-f - German fraktur
  • fra - French
  • ita - Italian
  • nld - Dutch
  • por - Portuguese
  • spa - Spanish
  • vie - Vietnamese
  • or any other supported by tesseract.

Note: Make sure you have installed the language to tesseract

Other options

  RTesseract.new('test.jpg', config_file: :digits)  # Only digit recognition

OR

  RTesseract.new('test.jpg', config_file: 'digits quiet')

BOUNDING BOX: TO GET WORDS WITH THEIR POSITIONS

  RTesseract.new('test_words.png').to_box
  => [
    {:word => 'If',  :x_start=>52, :y_start=>13, :x_end=>63, :y_end=>27},
    {:word => 'you', :x_start=>69, :y_start=>17, :x_end=>100, :y_end=>31},
    {:word => 'are', :x_start=>108, :y_start=>17, :x_end=>136, :y_end=>27},
    {:word => 'a', :x_start=>143, :y_start=>17, :x_end=>151, :y_end=>27},
    {:word => 'friend,', :x_start=>158, :y_start=>13, :x_end=>214, :y_end=>29},
    {:word => 'you', :x_start=>51, :y_start=>39, :x_end=>82, :y_end=>53},
    {:word => 'speak', :x_start=>90, :y_start=>35, :x_end=>140, :y_end=>53},
    {:word => 'the', :x_start=>146, :y_start=>35, :x_end=>174, :y_end=>49},
    {:word => 'password,', :x_start=>182, :y_start=>35, :x_end=>267, :y_end=>53},
    {:word => 'and', :x_start=>51, :y_start=>57, :x_end=>81, :y_end=>71},
    {:word => 'the', :x_start=>89, :y_start=>57, :x_end=>117, :y_end=>71},
    {:word => 'doors', :x_start=>124, :y_start=>57, :x_end=>172, :y_end=>71},
    {:word => 'will', :x_start=>180, :y_start=>57, :x_end=>208, :y_end=>71},
    {:word => 'open.', :x_start=>216, :y_start=>61, :x_end=>263, :y_end=>75}
  ]

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dannnylo/rtesseract. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Rtesseract project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

rtesseract's People

Contributors

abarrak avatar alexanderadam avatar antronin avatar dannnylo avatar debbbbie avatar espinosa avatar hooopo avatar jimi-c avatar joao avatar lukeasrodgers avatar luxflux avatar pumpchaser avatar scrumers avatar steakchaser avatar thiagoalessio avatar tjad avatar zprickett avatar

Watchers

 avatar  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.