Class: AsposeOCRCloud::OcrApi
- Inherits:
-
Object
- Object
- AsposeOCRCloud::OcrApi
- Defined in:
- lib/aspose_ocr_cloud/api/ocr_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#get_recognize_document(name, opts = {}) ⇒ OCRResponse
Recognize image text, language and text region can be selected, default dictionaries can be used for correction.
-
#initialize(api_client = nil) ⇒ OcrApi
constructor
A new instance of OcrApi.
-
#post_ocr_from_url_or_content(opts = {}) ⇒ OCRResponse
Recognize image text from some url if provided or from the request body content, language can be selected, default dictionaries can be used for correction.
Constructor Details
#initialize(api_client = nil) ⇒ OcrApi
Returns a new instance of OcrApi.
7 8 9 |
# File 'lib/aspose_ocr_cloud/api/ocr_api.rb', line 7 def initialize(api_client = nil) @api_client = api_client || Configuration.api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
5 6 7 |
# File 'lib/aspose_ocr_cloud/api/ocr_api.rb', line 5 def api_client @api_client end |
Instance Method Details
#get_recognize_document(name, opts = {}) ⇒ OCRResponse
Recognize image text, language and text region can be selected, default dictionaries can be used for correction.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/aspose_ocr_cloud/api/ocr_api.rb', line 79 def get_recognize_document(name, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: OcrApi#get_recognize_document ..." end # verify the required parameter 'name' is set fail "Missing the required parameter 'name' when calling get_recognize_document" if name.nil? # resource path path = "/ocr/{name}/recognize".sub('{format}','json').sub('{' + 'name' + '}', name.to_s) # query parameters query_params = {} query_params[:'language'] = opts[:'language'] if opts[:'language'] query_params[:'rectX'] = opts[:'rect_x'] if opts[:'rect_x'] query_params[:'rectY'] = opts[:'rect_y'] if opts[:'rect_y'] query_params[:'rectWidth'] = opts[:'rect_width'] if opts[:'rect_width'] query_params[:'rectHeight'] = opts[:'rect_height'] if opts[:'rect_height'] query_params[:'useDefaultDictionaries'] = opts[:'use_default_dictionaries'] if opts[:'use_default_dictionaries'] query_params[:'storage'] = opts[:'storage'] if opts[:'storage'] query_params[:'folder'] = opts[:'folder'] if opts[:'folder'] # header parameters header_params = {} # HTTP header 'Accept' (if needed) _header_accept = ['application/json', 'text/json', 'application/xml', 'text/xml', 'text/javascript'] _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result # HTTP header 'Content-Type' _header_content_type = [] header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil auth_names = [] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'OCRResponse') if Configuration.debugging Configuration.logger.debug "API called: OcrApi#get_recognize_document. Result: #{result.inspect}" end return result end |
#post_ocr_from_url_or_content(opts = {}) ⇒ OCRResponse
Recognize image text from some url if provided or from the request body content, language can be selected, default dictionaries can be used for correction.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/aspose_ocr_cloud/api/ocr_api.rb', line 19 def post_ocr_from_url_or_content(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: OcrApi#post_ocr_from_url_or_content ..." end # resource path path = "/ocr/recognize".sub('{format}','json') # query parameters query_params = {} query_params[:'url'] = opts[:'url'] if opts[:'url'] query_params[:'language'] = opts[:'language'] if opts[:'language'] query_params[:'useDefaultDictionaries'] = opts[:'use_default_dictionaries'] if opts[:'use_default_dictionaries'] # header parameters header_params = {} # HTTP header 'Accept' (if needed) _header_accept = ['application/json'] _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result # HTTP header 'Content-Type' _header_content_type = ['multipart/form-data'] header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) # form parameters form_params = {} form_params["file"] = opts[:'file'] if opts[:'file'] # http body (model) post_body = nil auth_names = [] result = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'OCRResponse') if Configuration.debugging Configuration.logger.debug "API called: OcrApi#post_ocr_from_url_or_content. Result: #{result.inspect}" end return result end |