cloudmersive-ocr-api-client

CloudmersiveOcrApiClient - the Ruby gem for the ocrapi

The powerful Optical Character Recognition (OCR) APIs let you convert scanned images of pages into recognized text.

This SDK is automatically generated by the Swagger Codegen project:

  • API version: v1
  • Package version: 1.5.0
  • Build package: io.swagger.codegen.languages.RubyClientCodegen

Installation

Build a gem

To build the Ruby code into a gem:

gem build cloudmersive-ocr-api-client.gemspec

Then either install the gem locally:

gem install ./cloudmersive-ocr-api-client-1.5.0.gem

(for development, run gem install --dev ./cloudmersive-ocr-api-client-1.5.0.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'cloudmersive-ocr-api-client', '~> 1.5.0'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:

gem 'cloudmersive-ocr-api-client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'cloudmersive-ocr-api-client'

# Setup authorization
CloudmersiveOcrApiClient.configure do |config|
  # Configure API key authorization: Apikey
  config.api_key['Apikey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['Apikey'] = 'Bearer'
end

api_instance = CloudmersiveOcrApiClient::ImageOcrApi.new

image_file = File.new("/path/to/file.txt") # File | Image file to perform OCR on.  Common file formats such as PNG, JPEG are supported.

opts = { 
  language: "language_example", # String | Optional, language of the input document, default is English (ENG).  Possible values are ENG (English), ARA (Arabic), ZHO (Chinese - Simplified), ZHO-HANT (Chinese - Traditional), ASM (Assamese), AFR (Afrikaans), AMH (Amharic), AZE (Azerbaijani), AZE-CYRL (Azerbaijani - Cyrillic), BEL (Belarusian), BEN (Bengali), BOD (Tibetan), BOS (Bosnian), BUL (Bulgarian), CAT (Catalan; Valencian), CEB (Cebuano), CES (Czech), CHR (Cherokee), CYM (Welsh), DAN (Danish), DEU (German), DZO (Dzongkha), ELL (Greek), ENM (Archaic/Middle English), EPO (Esperanto), EST (Estonian), EUS (Basque), FAS (Persian), FIN (Finnish), FRA (French), FRK (Frankish), FRM (Middle-French), GLE (Irish), GLG (Galician), GRC (Ancient Greek), HAT (Hatian), HEB (Hebrew), HIN (Hindi), HRV (Croatian), HUN (Hungarian), IKU (Inuktitut), IND (Indonesian), ISL (Icelandic), ITA (Italian), ITA-OLD (Old - Italian), JAV (Javanese), JPN (Japanese), KAN (Kannada), KAT (Georgian), KAT-OLD (Old-Georgian), KAZ (Kazakh), KHM (Central Khmer), KIR (Kirghiz), KOR (Korean), KUR (Kurdish), LAO (Lao), LAT (Latin), LAV (Latvian), LIT (Lithuanian), MAL (Malayalam), MAR (Marathi), MKD (Macedonian), MLT (Maltese), MSA (Malay), MYA (Burmese), NEP (Nepali), NLD (Dutch), NOR (Norwegian), ORI (Oriya), PAN (Panjabi), POL (Polish), POR (Portuguese), PUS (Pushto), RON (Romanian), RUS (Russian), SAN (Sanskrit), SIN (Sinhala), SLK (Slovak), SLV (Slovenian), SPA (Spanish), SPA-OLD (Old Spanish), SQI (Albanian), SRP (Serbian), SRP-LAT (Latin Serbian), SWA (Swahili), SWE (Swedish), SYR (Syriac), TAM (Tamil), TEL (Telugu), TGK (Tajik), TGL (Tagalog), THA (Thai), TIR (Tigrinya), TUR (Turkish), UIG (Uighur), UKR (Ukrainian), URD (Urdu), UZB (Uzbek), UZB-CYR (Cyrillic Uzbek), VIE (Vietnamese), YID (Yiddish)
  preprocessing: "preprocessing_example" # String | Optional, preprocessing mode, default is 'Auto'.  Possible values are None (no preprocessing of the image), and Auto (automatic image enhancement of the image before OCR is applied; this is recommended).
}

begin
  #Convert a scanned image into words with location
  result = api_instance.image_ocr_image_lines_with_location(image_file, opts)
  p result
rescue CloudmersiveOcrApiClient::ApiError => e
  puts "Exception when calling ImageOcrApi->image_ocr_image_lines_with_location: #{e}"
end

Documentation for API Endpoints

All URIs are relative to https://api.cloudmersive.com

Class Method HTTP request Description
CloudmersiveOcrApiClient::ImageOcrApi image_ocr_image_lines_with_location POST /ocr/image/to/lines-with-location Convert a scanned image into words with location
CloudmersiveOcrApiClient::ImageOcrApi image_ocr_image_words_with_location POST /ocr/image/to/words-with-location Convert a scanned image into words with location
CloudmersiveOcrApiClient::ImageOcrApi image_ocr_photo_recognize_business_card POST /ocr/photo/recognize/business-card Recognize a photo of a business card, extract key business information
CloudmersiveOcrApiClient::ImageOcrApi image_ocr_photo_recognize_form POST /ocr/photo/recognize/form Recognize a photo of a form, extract key fields and business information
CloudmersiveOcrApiClient::ImageOcrApi image_ocr_photo_recognize_form_advanced POST /ocr/photo/recognize/form/advanced Recognize a photo of a form, extract key fields using stored templates
CloudmersiveOcrApiClient::ImageOcrApi image_ocr_photo_recognize_receipt POST /ocr/photo/recognize/receipt Recognize a photo of a receipt, extract key business information
CloudmersiveOcrApiClient::ImageOcrApi image_ocr_photo_to_text POST /ocr/photo/toText Convert a photo of a document into text
CloudmersiveOcrApiClient::ImageOcrApi image_ocr_photo_words_with_location POST /ocr/photo/to/words-with-location Convert a photo of a document or receipt into words with location
CloudmersiveOcrApiClient::ImageOcrApi image_ocr_post POST /ocr/image/toText Convert a scanned image into text
CloudmersiveOcrApiClient::PdfOcrApi pdf_ocr_pdf_to_lines_with_location POST /ocr/pdf/to/lines-with-location Convert a PDF into text lines with location
CloudmersiveOcrApiClient::PdfOcrApi pdf_ocr_pdf_to_words_with_location POST /ocr/pdf/to/words-with-location Convert a PDF into words with location
CloudmersiveOcrApiClient::PdfOcrApi pdf_ocr_post POST /ocr/pdf/toText Converts an uploaded PDF file into text via Optical Character Recognition.
CloudmersiveOcrApiClient::PreprocessingApi preprocessing_binarize POST /ocr/preprocessing/image/binarize Convert an image of text into a binarized (light and dark) view
CloudmersiveOcrApiClient::PreprocessingApi preprocessing_binarize_advanced POST /ocr/preprocessing/image/binarize/advanced Convert an image of text into a binary (light and dark) view with ML
CloudmersiveOcrApiClient::PreprocessingApi preprocessing_get_page_angle POST /ocr/preprocessing/image/get-page-angle Get the angle of the page / document / receipt
CloudmersiveOcrApiClient::PreprocessingApi preprocessing_unrotate POST /ocr/preprocessing/image/unrotate Detect and unrotate a document image
CloudmersiveOcrApiClient::PreprocessingApi preprocessing_unrotate_advanced POST /ocr/preprocessing/image/unrotate/advanced Detect and unrotate a document image (advanced)
CloudmersiveOcrApiClient::PreprocessingApi preprocessing_unskew POST /ocr/preprocessing/image/unskew Detect and unskew a photo of a document
CloudmersiveOcrApiClient::ReceiptsApi receipts_photo_to_csv POST /ocr/receipts/photo/to/csv Convert a photo of a receipt into a CSV file containing structured information from the receipt

Documentation for Models

Documentation for Authorization

Apikey

  • Type: API key
  • API key parameter name: Apikey
  • Location: HTTP header