cloudmersive-ocr-api-client 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +111 -0
  4. data/Rakefile +8 -0
  5. data/cloudmersive-ocr-api-client.gemspec +45 -0
  6. data/docs/ImageOcrApi.md +128 -0
  7. data/docs/ImageToTextResponse.md +9 -0
  8. data/docs/OcrPageResult.md +10 -0
  9. data/docs/PdfOcrApi.md +67 -0
  10. data/docs/PdfToTextResponse.md +9 -0
  11. data/docs/PreprocessingApi.md +118 -0
  12. data/git_push.sh +55 -0
  13. data/lib/cloudmersive-ocr-api-client.rb +45 -0
  14. data/lib/cloudmersive-ocr-api-client/api/image_ocr_api.rb +144 -0
  15. data/lib/cloudmersive-ocr-api-client/api/pdf_ocr_api.rb +85 -0
  16. data/lib/cloudmersive-ocr-api-client/api/preprocessing_api.rb +135 -0
  17. data/lib/cloudmersive-ocr-api-client/api_client.rb +389 -0
  18. data/lib/cloudmersive-ocr-api-client/api_error.rb +38 -0
  19. data/lib/cloudmersive-ocr-api-client/configuration.rb +209 -0
  20. data/lib/cloudmersive-ocr-api-client/models/image_to_text_response.rb +199 -0
  21. data/lib/cloudmersive-ocr-api-client/models/ocr_page_result.rb +209 -0
  22. data/lib/cloudmersive-ocr-api-client/models/pdf_to_text_response.rb +199 -0
  23. data/lib/cloudmersive-ocr-api-client/version.rb +15 -0
  24. data/spec/api/image_ocr_api_spec.rb +62 -0
  25. data/spec/api/pdf_ocr_api_spec.rb +49 -0
  26. data/spec/api/preprocessing_api_spec.rb +59 -0
  27. data/spec/api_client_spec.rb +226 -0
  28. data/spec/configuration_spec.rb +42 -0
  29. data/spec/models/image_to_text_response_spec.rb +48 -0
  30. data/spec/models/ocr_page_result_spec.rb +54 -0
  31. data/spec/models/pdf_to_text_response_spec.rb +48 -0
  32. data/spec/spec_helper.rb +111 -0
  33. metadata +255 -0
data/git_push.sh ADDED
@@ -0,0 +1,55 @@
1
+ #!/bin/sh
2
+ #
3
+ # Generated by: https://github.com/swagger-api/swagger-codegen.git
4
+ #
5
+ # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
6
+ #
7
+ # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
8
+
9
+ git_user_id=$1
10
+ git_repo_id=$2
11
+ release_note=$3
12
+
13
+ if [ "$git_user_id" = "" ]; then
14
+ git_user_id="GIT_USER_ID"
15
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
16
+ fi
17
+
18
+ if [ "$git_repo_id" = "" ]; then
19
+ git_repo_id="GIT_REPO_ID"
20
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
21
+ fi
22
+
23
+ if [ "$release_note" = "" ]; then
24
+ release_note="Minor update"
25
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
26
+ fi
27
+
28
+ # Initialize the local directory as a Git repository
29
+ git init
30
+
31
+ # Adds the files in the local repository and stages them for commit.
32
+ git add .
33
+
34
+ # Commits the tracked changes and prepares them to be pushed to a remote repository.
35
+ git commit -m "$release_note"
36
+
37
+ # Sets the new remote
38
+ git_remote=`git remote`
39
+ if [ "$git_remote" = "" ]; then # git remote not defined
40
+
41
+ if [ "$GIT_TOKEN" = "" ]; then
42
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
43
+ git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
44
+ else
45
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
46
+ fi
47
+
48
+ fi
49
+
50
+ git pull origin master
51
+
52
+ # Pushes (Forces) the changes in the local repository up to the remote repository
53
+ echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
54
+ git push origin master 2>&1 | grep -v 'To https'
55
+
@@ -0,0 +1,45 @@
1
+ =begin
2
+ #ocrapi
3
+
4
+ #The powerful Optical Character Recognition (OCR) APIs let you convert scanned images of pages into recognized text.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ # Common files
14
+ require 'cloudmersive-ocr-api-client/api_client'
15
+ require 'cloudmersive-ocr-api-client/api_error'
16
+ require 'cloudmersive-ocr-api-client/version'
17
+ require 'cloudmersive-ocr-api-client/configuration'
18
+
19
+ # Models
20
+ require 'cloudmersive-ocr-api-client/models/image_to_text_response'
21
+ require 'cloudmersive-ocr-api-client/models/ocr_page_result'
22
+ require 'cloudmersive-ocr-api-client/models/pdf_to_text_response'
23
+
24
+ # APIs
25
+ require 'cloudmersive-ocr-api-client/api/image_ocr_api'
26
+ require 'cloudmersive-ocr-api-client/api/pdf_ocr_api'
27
+ require 'cloudmersive-ocr-api-client/api/preprocessing_api'
28
+
29
+ module CloudmersiveOcrApiClient
30
+ class << self
31
+ # Customize default settings for the SDK using block.
32
+ # CloudmersiveOcrApiClient.configure do |config|
33
+ # config.username = "xxx"
34
+ # config.password = "xxx"
35
+ # end
36
+ # If no block given, return the default Configuration object.
37
+ def configure
38
+ if block_given?
39
+ yield(Configuration.default)
40
+ else
41
+ Configuration.default
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,144 @@
1
+ =begin
2
+ #ocrapi
3
+
4
+ #The powerful Optical Character Recognition (OCR) APIs let you convert scanned images of pages into recognized text.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require "uri"
14
+
15
+ module CloudmersiveOcrApiClient
16
+ class ImageOcrApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+
23
+ # Convert a photo of a document into text
24
+ # Converts an uploaded photo of a document in common formats such as JPEG, PNG into text via Optical Character Recognition. This API is intended to be run on photos of documents, e.g. taken with a smartphone and supports cases where other content, such as a desk, are in the frame and the camera is crooked. If you want to OCR a scanned image, use the image/toText API call instead as it is designed for scanned images.
25
+ # @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
26
+ # @param [Hash] opts the optional parameters
27
+ # @option opts [String] :language 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)
28
+ # @return [ImageToTextResponse]
29
+ def image_ocr_photo_to_text(image_file, opts = {})
30
+ data, _status_code, _headers = image_ocr_photo_to_text_with_http_info(image_file, opts)
31
+ return data
32
+ end
33
+
34
+ # Convert a photo of a document into text
35
+ # Converts an uploaded photo of a document in common formats such as JPEG, PNG into text via Optical Character Recognition. This API is intended to be run on photos of documents, e.g. taken with a smartphone and supports cases where other content, such as a desk, are in the frame and the camera is crooked. If you want to OCR a scanned image, use the image/toText API call instead as it is designed for scanned images.
36
+ # @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
37
+ # @param [Hash] opts the optional parameters
38
+ # @option opts [String] :language 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)
39
+ # @return [Array<(ImageToTextResponse, Fixnum, Hash)>] ImageToTextResponse data, response status code and response headers
40
+ def image_ocr_photo_to_text_with_http_info(image_file, opts = {})
41
+ if @api_client.config.debugging
42
+ @api_client.config.logger.debug "Calling API: ImageOcrApi.image_ocr_photo_to_text ..."
43
+ end
44
+ # verify the required parameter 'image_file' is set
45
+ if @api_client.config.client_side_validation && image_file.nil?
46
+ fail ArgumentError, "Missing the required parameter 'image_file' when calling ImageOcrApi.image_ocr_photo_to_text"
47
+ end
48
+ # resource path
49
+ local_var_path = "/ocr/photo/toText"
50
+
51
+ # query parameters
52
+ query_params = {}
53
+
54
+ # header parameters
55
+ header_params = {}
56
+ # HTTP header 'Accept' (if needed)
57
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
58
+ # HTTP header 'Content-Type'
59
+ header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
60
+ header_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?
61
+
62
+ # form parameters
63
+ form_params = {}
64
+ form_params["imageFile"] = image_file
65
+
66
+ # http body (model)
67
+ post_body = nil
68
+ auth_names = ['Apikey']
69
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
70
+ :header_params => header_params,
71
+ :query_params => query_params,
72
+ :form_params => form_params,
73
+ :body => post_body,
74
+ :auth_names => auth_names,
75
+ :return_type => 'ImageToTextResponse')
76
+ if @api_client.config.debugging
77
+ @api_client.config.logger.debug "API called: ImageOcrApi#image_ocr_photo_to_text\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
78
+ end
79
+ return data, status_code, headers
80
+ end
81
+
82
+ # Convert a scanned image into text
83
+ # Converts an uploaded image in common formats such as JPEG, PNG into text via Optical Character Recognition. This API is intended to be run on scanned documents. If you want to OCR photos (e.g. taken with a smart phone camera), be sure to use the photo/toText API instead, as it is designed to unskew the image first.
84
+ # @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
85
+ # @param [Hash] opts the optional parameters
86
+ # @option opts [String] :language 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)
87
+ # @option opts [String] :preprocessing Optional, preprocessing mode, default is &#39;Auto&#39;. Possible values are None (no preprocessing of the image), and Auto (automatic image enhancement of the image before OCR is applied; this is recommended).
88
+ # @return [ImageToTextResponse]
89
+ def image_ocr_post(image_file, opts = {})
90
+ data, _status_code, _headers = image_ocr_post_with_http_info(image_file, opts)
91
+ return data
92
+ end
93
+
94
+ # Convert a scanned image into text
95
+ # Converts an uploaded image in common formats such as JPEG, PNG into text via Optical Character Recognition. This API is intended to be run on scanned documents. If you want to OCR photos (e.g. taken with a smart phone camera), be sure to use the photo/toText API instead, as it is designed to unskew the image first.
96
+ # @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
97
+ # @param [Hash] opts the optional parameters
98
+ # @option opts [String] :language 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)
99
+ # @option opts [String] :preprocessing Optional, preprocessing mode, default is &#39;Auto&#39;. Possible values are None (no preprocessing of the image), and Auto (automatic image enhancement of the image before OCR is applied; this is recommended).
100
+ # @return [Array<(ImageToTextResponse, Fixnum, Hash)>] ImageToTextResponse data, response status code and response headers
101
+ def image_ocr_post_with_http_info(image_file, opts = {})
102
+ if @api_client.config.debugging
103
+ @api_client.config.logger.debug "Calling API: ImageOcrApi.image_ocr_post ..."
104
+ end
105
+ # verify the required parameter 'image_file' is set
106
+ if @api_client.config.client_side_validation && image_file.nil?
107
+ fail ArgumentError, "Missing the required parameter 'image_file' when calling ImageOcrApi.image_ocr_post"
108
+ end
109
+ # resource path
110
+ local_var_path = "/ocr/image/toText"
111
+
112
+ # query parameters
113
+ query_params = {}
114
+
115
+ # header parameters
116
+ header_params = {}
117
+ # HTTP header 'Accept' (if needed)
118
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
119
+ # HTTP header 'Content-Type'
120
+ header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
121
+ header_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?
122
+ header_params[:'preprocessing'] = opts[:'preprocessing'] if !opts[:'preprocessing'].nil?
123
+
124
+ # form parameters
125
+ form_params = {}
126
+ form_params["imageFile"] = image_file
127
+
128
+ # http body (model)
129
+ post_body = nil
130
+ auth_names = ['Apikey']
131
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
132
+ :header_params => header_params,
133
+ :query_params => query_params,
134
+ :form_params => form_params,
135
+ :body => post_body,
136
+ :auth_names => auth_names,
137
+ :return_type => 'ImageToTextResponse')
138
+ if @api_client.config.debugging
139
+ @api_client.config.logger.debug "API called: ImageOcrApi#image_ocr_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
140
+ end
141
+ return data, status_code, headers
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,85 @@
1
+ =begin
2
+ #ocrapi
3
+
4
+ #The powerful Optical Character Recognition (OCR) APIs let you convert scanned images of pages into recognized text.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require "uri"
14
+
15
+ module CloudmersiveOcrApiClient
16
+ class PdfOcrApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+
23
+ # Converts an uploaded image in common formats such as JPEG, PNG into text via Optical Character Recognition.
24
+ #
25
+ # @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
26
+ # @param [Hash] opts the optional parameters
27
+ # @option opts [String] :language 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)
28
+ # @option opts [String] :preprocessing Optional, preprocessing mode, default is &#39;Auto&#39;. Possible values are None (no preprocessing of the image), and Auto (automatic image enhancement of the image before OCR is applied; this is recommended).
29
+ # @return [PdfToTextResponse]
30
+ def pdf_ocr_post(image_file, opts = {})
31
+ data, _status_code, _headers = pdf_ocr_post_with_http_info(image_file, opts)
32
+ return data
33
+ end
34
+
35
+ # Converts an uploaded image in common formats such as JPEG, PNG into text via Optical Character Recognition.
36
+ #
37
+ # @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
38
+ # @param [Hash] opts the optional parameters
39
+ # @option opts [String] :language 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)
40
+ # @option opts [String] :preprocessing Optional, preprocessing mode, default is &#39;Auto&#39;. Possible values are None (no preprocessing of the image), and Auto (automatic image enhancement of the image before OCR is applied; this is recommended).
41
+ # @return [Array<(PdfToTextResponse, Fixnum, Hash)>] PdfToTextResponse data, response status code and response headers
42
+ def pdf_ocr_post_with_http_info(image_file, opts = {})
43
+ if @api_client.config.debugging
44
+ @api_client.config.logger.debug "Calling API: PdfOcrApi.pdf_ocr_post ..."
45
+ end
46
+ # verify the required parameter 'image_file' is set
47
+ if @api_client.config.client_side_validation && image_file.nil?
48
+ fail ArgumentError, "Missing the required parameter 'image_file' when calling PdfOcrApi.pdf_ocr_post"
49
+ end
50
+ # resource path
51
+ local_var_path = "/ocr/pdf/toText"
52
+
53
+ # query parameters
54
+ query_params = {}
55
+
56
+ # header parameters
57
+ header_params = {}
58
+ # HTTP header 'Accept' (if needed)
59
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
60
+ # HTTP header 'Content-Type'
61
+ header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
62
+ header_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?
63
+ header_params[:'preprocessing'] = opts[:'preprocessing'] if !opts[:'preprocessing'].nil?
64
+
65
+ # form parameters
66
+ form_params = {}
67
+ form_params["imageFile"] = image_file
68
+
69
+ # http body (model)
70
+ post_body = nil
71
+ auth_names = ['Apikey']
72
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
73
+ :header_params => header_params,
74
+ :query_params => query_params,
75
+ :form_params => form_params,
76
+ :body => post_body,
77
+ :auth_names => auth_names,
78
+ :return_type => 'PdfToTextResponse')
79
+ if @api_client.config.debugging
80
+ @api_client.config.logger.debug "API called: PdfOcrApi#pdf_ocr_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
81
+ end
82
+ return data, status_code, headers
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,135 @@
1
+ =begin
2
+ #ocrapi
3
+
4
+ #The powerful Optical Character Recognition (OCR) APIs let you convert scanned images of pages into recognized text.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require "uri"
14
+
15
+ module CloudmersiveOcrApiClient
16
+ class PreprocessingApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+
23
+ # Detect and unrotate a document image
24
+ # Detect and unrotate an image of a document (e.g. that was scanned at an angle). Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
25
+ # @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
26
+ # @param [Hash] opts the optional parameters
27
+ # @return [Object]
28
+ def preprocessing_unrotate(image_file, opts = {})
29
+ data, _status_code, _headers = preprocessing_unrotate_with_http_info(image_file, opts)
30
+ return data
31
+ end
32
+
33
+ # Detect and unrotate a document image
34
+ # Detect and unrotate an image of a document (e.g. that was scanned at an angle). Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
35
+ # @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
36
+ # @param [Hash] opts the optional parameters
37
+ # @return [Array<(Object, Fixnum, Hash)>] Object data, response status code and response headers
38
+ def preprocessing_unrotate_with_http_info(image_file, opts = {})
39
+ if @api_client.config.debugging
40
+ @api_client.config.logger.debug "Calling API: PreprocessingApi.preprocessing_unrotate ..."
41
+ end
42
+ # verify the required parameter 'image_file' is set
43
+ if @api_client.config.client_side_validation && image_file.nil?
44
+ fail ArgumentError, "Missing the required parameter 'image_file' when calling PreprocessingApi.preprocessing_unrotate"
45
+ end
46
+ # resource path
47
+ local_var_path = "/ocr/preprocessing/image/unrotate"
48
+
49
+ # query parameters
50
+ query_params = {}
51
+
52
+ # header parameters
53
+ header_params = {}
54
+ # HTTP header 'Accept' (if needed)
55
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
56
+ # HTTP header 'Content-Type'
57
+ header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
58
+
59
+ # form parameters
60
+ form_params = {}
61
+ form_params["imageFile"] = image_file
62
+
63
+ # http body (model)
64
+ post_body = nil
65
+ auth_names = ['Apikey']
66
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
67
+ :header_params => header_params,
68
+ :query_params => query_params,
69
+ :form_params => form_params,
70
+ :body => post_body,
71
+ :auth_names => auth_names,
72
+ :return_type => 'Object')
73
+ if @api_client.config.debugging
74
+ @api_client.config.logger.debug "API called: PreprocessingApi#preprocessing_unrotate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
75
+ end
76
+ return data, status_code, headers
77
+ end
78
+
79
+ # Detect and unskew a photo of a document
80
+ # Detect and unskew a photo of a document (e.g. taken on a cell phone) into a perfectly square image. Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
81
+ # @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
82
+ # @param [Hash] opts the optional parameters
83
+ # @return [Object]
84
+ def preprocessing_unskew(image_file, opts = {})
85
+ data, _status_code, _headers = preprocessing_unskew_with_http_info(image_file, opts)
86
+ return data
87
+ end
88
+
89
+ # Detect and unskew a photo of a document
90
+ # Detect and unskew a photo of a document (e.g. taken on a cell phone) into a perfectly square image. Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
91
+ # @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
92
+ # @param [Hash] opts the optional parameters
93
+ # @return [Array<(Object, Fixnum, Hash)>] Object data, response status code and response headers
94
+ def preprocessing_unskew_with_http_info(image_file, opts = {})
95
+ if @api_client.config.debugging
96
+ @api_client.config.logger.debug "Calling API: PreprocessingApi.preprocessing_unskew ..."
97
+ end
98
+ # verify the required parameter 'image_file' is set
99
+ if @api_client.config.client_side_validation && image_file.nil?
100
+ fail ArgumentError, "Missing the required parameter 'image_file' when calling PreprocessingApi.preprocessing_unskew"
101
+ end
102
+ # resource path
103
+ local_var_path = "/ocr/preprocessing/image/unskew"
104
+
105
+ # query parameters
106
+ query_params = {}
107
+
108
+ # header parameters
109
+ header_params = {}
110
+ # HTTP header 'Accept' (if needed)
111
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
112
+ # HTTP header 'Content-Type'
113
+ header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
114
+
115
+ # form parameters
116
+ form_params = {}
117
+ form_params["imageFile"] = image_file
118
+
119
+ # http body (model)
120
+ post_body = nil
121
+ auth_names = ['Apikey']
122
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
123
+ :header_params => header_params,
124
+ :query_params => query_params,
125
+ :form_params => form_params,
126
+ :body => post_body,
127
+ :auth_names => auth_names,
128
+ :return_type => 'Object')
129
+ if @api_client.config.debugging
130
+ @api_client.config.logger.debug "API called: PreprocessingApi#preprocessing_unskew\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
131
+ end
132
+ return data, status_code, headers
133
+ end
134
+ end
135
+ end