{"id":15406183,"url":"https://github.com/meh/ruby-tesseract-ocr","last_synced_at":"2025-05-15T17:08:52.580Z","repository":{"id":1928042,"uuid":"2856487","full_name":"meh/ruby-tesseract-ocr","owner":"meh","description":"A Ruby wrapper library to the tesseract-ocr API.","archived":false,"fork":false,"pushed_at":"2017-07-02T12:07:20.000Z","size":575,"stargazers_count":631,"open_issues_count":24,"forks_count":73,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-05-11T23:03:46.637Z","etag":null,"topics":["ruby","rubynlp","tesseract-ocr","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-11-26T16:56:35.000Z","updated_at":"2025-02-20T00:02:20.000Z","dependencies_parsed_at":"2022-08-21T01:50:31.969Z","dependency_job_id":null,"html_url":"https://github.com/meh/ruby-tesseract-ocr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meh%2Fruby-tesseract-ocr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meh%2Fruby-tesseract-ocr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meh%2Fruby-tesseract-ocr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meh%2Fruby-tesseract-ocr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meh","download_url":"https://codeload.github.com/meh/ruby-tesseract-ocr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384989,"owners_count":22062422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","rubynlp","tesseract-ocr","wrapper"],"created_at":"2024-10-01T16:19:51.260Z","updated_at":"2025-05-15T17:08:47.567Z","avatar_url":"https://github.com/meh.png","language":"Ruby","funding_links":[],"categories":["Ruby","Software","Optical Character Recognition"],"sub_categories":["OCR libraries by programming language","Text-to-Speech-to-Text"],"readme":"ruby-tesseract - Ruby bindings and wrapper\n==========================================\nThis wrapper binds the TessBaseAPI object through ffi-inline (which means it\nwill work on JRuby too) and then proceeds to wrap said API in a more ruby-esque\nEngine class.\n\nMaking it work\n--------------\nTo make this library work you need tesseract-ocr and leptonica libraries and\nheaders and a C++ compiler.\n\nThe gem is called `tesseract-ocr`.\n\nIf you're on a distribution that separates the libraries from headers, remember\nto install the *-dev* package.\n\nOn Debian you will need to install `libleptonica-dev` and `libtesseract-dev`.\n\nExamples\n--------\nFollowing are some examples that show the functionalities provided by\ntesseract-ocr.\n\n### Basic functionality of tesseract\n\n```ruby\nrequire 'tesseract'\n\ne = Tesseract::Engine.new {|e|\n  e.language  = :eng\n  e.blacklist = '|'\n}\n\ne.text_for('test/first.png').strip # =\u003e 'ABC'\n```\n\nYou can pass to `#text_for` either a path, an IO object, a string containing\nthe image or an object that responds to `#to_blob` (for example\nMagick::Image), keep in mind that the format has to be supported by leptonica.\n\n### Accessing advanced features\n\nWith advanced features you get access to blocks, paragraphs, lines, words and\nsymbols.\n\nReplace **level** in method names with either `block`, `paragraph`, `line`,\n`word` or `symbol`.\n\nThe following kind of accessors need a block to be passed and they pass to the\nblock each `Element` object. The Element object has various getters to access\ncertain features, I'll talk about them later.\n\nThe methods are:\n\n* `each_level`\n* `each_level_for`\n* `each_level_at`\n\nThe following accessors instead return an `Array` of `Element`s with cached\ngetters, the getters are cached beacause the values accessible in the `Element`\nare linked to the state of the internal API, and that state changes if you\naccess something else.\n\nThe methods are:\n\n*\t`levels`\n*\t`levels_for`\n*\t`levels_at`\n\nAgain, to `*_for` methods you can pass what you can pass to a `#text_for`.\n\nEach `Element` object has the following getters:\n\n* `bounding_box`, this will return the box where the element is confined into\n* `binary_image`, this will return the bichromatic image of the element\n* `image`, this will return the image of the element\n* `baseline`, this will return the line where the text is with a pair of\n  coordinates\n* `orientation`, this will return the orientation of the element\n* `text`, this will return the text of the element\n* `confidence`, this will return the confidence of correctness for the element\n\n`Block` elements also have `type` accessors that specify the type of the block.\n\n`Word` elements also have `font_attributes`, `from_dictionary?` and `numeric?`\ngetters.\n\n`Symbol` elements also have `superscript?`, `subscript?` and `dropcap?`\ngetters.\n\n### hOCR\n\n```ruby\nrequire 'tesseract'\n\ne = Tesseract::Engine.new {|e|\n  e.language  = :eng\n  e.blacklist = '|'\n}\n\nputs e.hocr_for('test/first.png')\n```\n\nYou can pass to `#hocr_for` either a path, an IO object, a string containing\nthe image or an object that responds to `#to_blob` (for example\nMagick::Image), keep in mind that the format has to be supported by leptonica.\n\nPlease note you have to pass `#hocr_for` the page you want to get the output of\nas well.\n\nUsing the binary\n----------------\nYou can also use the shipped executable in the following way:\n\n```bash\n\u003e tesseract.rb -h\nUsage: tesseract [options]\n        --path PATH                  datapath to set\n    -l, --language LANGUAGE          language to use\n    -m, --mode MODE                  mode to use\n    -p, --psm MODE                   page segmentation mode to use\n    -u, --unlv                       output in UNLV format\n    -c, --confidence                 output the mean confidence of the recognition\n    -C, --config PATH...             config files to load\n    -b, --blacklist LIST             blacklist the following chars\n    -w, --whitelist LIST             whitelist the following chars\n\u003e tesseract.rb test/first.png \nABC\n\u003e tesseract.rb -c test/first.png \n86\n```\n\nLicense\n-------\nThe license is BSD one clause.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeh%2Fruby-tesseract-ocr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeh%2Fruby-tesseract-ocr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeh%2Fruby-tesseract-ocr/lists"}