All Projects → meh → Ruby Tesseract Ocr

meh / Ruby Tesseract Ocr

A Ruby wrapper library to the tesseract-ocr API.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Ruby Tesseract Ocr

React Native Tesseract Ocr
Tesseract OCR wrapper for React Native
Stars: ✭ 384 (-36.11%)
Mutual labels:  tesseract-ocr
Seq2seqchatbots
A wrapper around tensor2tensor to flexibly train, interact, and generate data for neural chatbots.
Stars: ✭ 466 (-22.46%)
Mutual labels:  wrapper
Tcconfig
A tc command wrapper. Make it easy to set up traffic control of network bandwidth/latency/packet-loss/packet-corruption/etc. to a network-interface/Docker-container(veth).
Stars: ✭ 510 (-15.14%)
Mutual labels:  wrapper
Scfacebook
The SCFacebook 4.1 is a simple and cleaner to use the api facebook-ios-sdk Objective-C Wrapper (https://github.com/facebook/facebook-ios-sdk) to perform login, get friends list, information about the user and posting on the wall with ^Block for iPhone. Suporte 4.71 FBSDKCoreKit, FBSDKShareKit and FBSDKLoginKit. Facebook SDK
Stars: ✭ 420 (-30.12%)
Mutual labels:  wrapper
Mogrify
Image processing in Elixir (ImageMagick command line wrapper)
Stars: ✭ 442 (-26.46%)
Mutual labels:  wrapper
Flapigen Rs
Tool for connecting programs or libraries written in Rust with other languages
Stars: ✭ 473 (-21.3%)
Mutual labels:  wrapper
Sparqlwrapper
A wrapper for a remote SPARQL endpoint
Stars: ✭ 365 (-39.27%)
Mutual labels:  wrapper
Atlassian Python Api
Atlassian Python REST API wrapper
Stars: ✭ 564 (-6.16%)
Mutual labels:  wrapper
Dxwrapper
Fixes compatibility issues with older games running on Windows 10 by wrapping DirectX dlls. Also allows loading custom libraries with the file extension .asi into game processes.
Stars: ✭ 460 (-23.46%)
Mutual labels:  wrapper
Rxfirebase
Rxjava 2.0 wrapper on Google's Android Firebase library.
Stars: ✭ 509 (-15.31%)
Mutual labels:  wrapper
Jsstore
A complete IndexedDB wrapper with SQL like syntax.
Stars: ✭ 430 (-28.45%)
Mutual labels:  wrapper
Docker Aosp
🏗 Minimal Android AOSP build environment with handy automation wrapper scripts
Stars: ✭ 440 (-26.79%)
Mutual labels:  wrapper
Imgui Go
Go wrapper library for "Dear ImGui" (https://github.com/ocornut/imgui)
Stars: ✭ 499 (-16.97%)
Mutual labels:  wrapper
Aspect Injector
AOP framework for .NET (c#, vb, etc)
Stars: ✭ 398 (-33.78%)
Mutual labels:  wrapper
Qtsharp
Mono/.NET bindings for Qt
Stars: ✭ 532 (-11.48%)
Mutual labels:  wrapper
Go Dotnet
Go wrapper for the .NET Core Runtime.
Stars: ✭ 369 (-38.6%)
Mutual labels:  wrapper
Goffmpeg
FFMPEG wrapper written in GO
Stars: ✭ 469 (-21.96%)
Mutual labels:  wrapper
Highcharter
R wrapper for highcharts
Stars: ✭ 583 (-3%)
Mutual labels:  wrapper
Python Poloniex
Poloniex API wrapper for Python 2.7 & 3
Stars: ✭ 557 (-7.32%)
Mutual labels:  wrapper
Materialdrawerkt
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library.
Stars: ✭ 508 (-15.47%)
Mutual labels:  wrapper

ruby-tesseract - Ruby bindings and wrapper

This wrapper binds the TessBaseAPI object through ffi-inline (which means it will work on JRuby too) and then proceeds to wrap said API in a more ruby-esque Engine class.

Making it work

To make this library work you need tesseract-ocr and leptonica libraries and headers and a C++ compiler.

The gem is called tesseract-ocr.

If you're on a distribution that separates the libraries from headers, remember to install the -dev package.

On Debian you will need to install libleptonica-dev and libtesseract-dev.

Examples

Following are some examples that show the functionalities provided by tesseract-ocr.

Basic functionality of tesseract

require 'tesseract'

e = Tesseract::Engine.new {|e|
  e.language  = :eng
  e.blacklist = '|'
}

e.text_for('test/first.png').strip # => 'ABC'

You can pass to #text_for either a path, an IO object, a string containing the image or an object that responds to #to_blob (for example Magick::Image), keep in mind that the format has to be supported by leptonica.

Accessing advanced features

With advanced features you get access to blocks, paragraphs, lines, words and symbols.

Replace level in method names with either block, paragraph, line, word or symbol.

The following kind of accessors need a block to be passed and they pass to the block each Element object. The Element object has various getters to access certain features, I'll talk about them later.

The methods are:

  • each_level
  • each_level_for
  • each_level_at

The following accessors instead return an Array of Elements with cached getters, the getters are cached beacause the values accessible in the Element are linked to the state of the internal API, and that state changes if you access something else.

The methods are:

  • levels
  • levels_for
  • levels_at

Again, to *_for methods you can pass what you can pass to a #text_for.

Each Element object has the following getters:

  • bounding_box, this will return the box where the element is confined into
  • binary_image, this will return the bichromatic image of the element
  • image, this will return the image of the element
  • baseline, this will return the line where the text is with a pair of coordinates
  • orientation, this will return the orientation of the element
  • text, this will return the text of the element
  • confidence, this will return the confidence of correctness for the element

Block elements also have type accessors that specify the type of the block.

Word elements also have font_attributes, from_dictionary? and numeric? getters.

Symbol elements also have superscript?, subscript? and dropcap? getters.

hOCR

require 'tesseract'

e = Tesseract::Engine.new {|e|
  e.language  = :eng
  e.blacklist = '|'
}

puts e.hocr_for('test/first.png')

You can pass to #hocr_for either a path, an IO object, a string containing the image or an object that responds to #to_blob (for example Magick::Image), keep in mind that the format has to be supported by leptonica.

Please note you have to pass #hocr_for the page you want to get the output of as well.

Using the binary

You can also use the shipped executable in the following way:

> tesseract.rb -h
Usage: tesseract [options]
        --path PATH                  datapath to set
    -l, --language LANGUAGE          language to use
    -m, --mode MODE                  mode to use
    -p, --psm MODE                   page segmentation mode to use
    -u, --unlv                       output in UNLV format
    -c, --confidence                 output the mean confidence of the recognition
    -C, --config PATH...             config files to load
    -b, --blacklist LIST             blacklist the following chars
    -w, --whitelist LIST             whitelist the following chars
> tesseract.rb test/first.png 
ABC
> tesseract.rb -c test/first.png 
86

License

The license is BSD one clause.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].