Class: Azure::CognitiveServices::ComputerVision::V1_0::ComputerVisionClient
- Inherits:
-
MsRestAzure::AzureServiceClient
- Object
- MsRestAzure::AzureServiceClient
- Azure::CognitiveServices::ComputerVision::V1_0::ComputerVisionClient
- Includes:
- MsRestAzure, MsRestAzure::Serialization
- Defined in:
- lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb
Overview
A service client - single point of access to the REST API.
Instance Attribute Summary collapse
-
#accept_language ⇒ String
The preferred language for the response.
-
#azure_region ⇒ AzureRegions
endpoints.
-
#base_url ⇒ String
readonly
The base URI of the service.
-
#credentials ⇒ Object
readonly
Credentials needed for the client to connect to Azure.
-
#generate_client_request_id ⇒ Boolean
generated.
-
#long_running_operation_retry_timeout ⇒ Integer
Operations.
Instance Method Summary collapse
-
#analyze_image(url, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ ImageAnalysis
This operation extracts a rich set of visual features based on the image content.
-
#analyze_image_async(url, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation extracts a rich set of visual features based on the image content.
-
#analyze_image_by_domain(model, url, language: nil, custom_headers: nil) ⇒ DomainModelResults
This operation recognizes content within an image by applying a domain-specific model.
-
#analyze_image_by_domain_async(model, url, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation recognizes content within an image by applying a domain-specific model.
-
#analyze_image_by_domain_in_stream(model, image, language: nil, custom_headers: nil) ⇒ DomainModelResults
This operation recognizes content within an image by applying a domain-specific model.
-
#analyze_image_by_domain_in_stream_async(model, image, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation recognizes content within an image by applying a domain-specific model.
-
#analyze_image_by_domain_in_stream_with_http_info(model, image, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation recognizes content within an image by applying a domain-specific model.
-
#analyze_image_by_domain_with_http_info(model, url, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation recognizes content within an image by applying a domain-specific model.
-
#analyze_image_in_stream(image, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ ImageAnalysis
This operation extracts a rich set of visual features based on the image content.
-
#analyze_image_in_stream_async(image, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation extracts a rich set of visual features based on the image content.
-
#analyze_image_in_stream_with_http_info(image, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation extracts a rich set of visual features based on the image content.
-
#analyze_image_with_http_info(url, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation extracts a rich set of visual features based on the image content.
-
#describe_image(url, max_candidates: '1', language: nil, custom_headers: nil) ⇒ ImageDescription
This operation generates a description of an image in human readable language with complete sentences.
-
#describe_image_async(url, max_candidates: '1', language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a description of an image in human readable language with complete sentences.
-
#describe_image_in_stream(image, max_candidates: '1', language: nil, custom_headers: nil) ⇒ ImageDescription
This operation generates a description of an image in human readable language with complete sentences.
-
#describe_image_in_stream_async(image, max_candidates: '1', language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a description of an image in human readable language with complete sentences.
-
#describe_image_in_stream_with_http_info(image, max_candidates: '1', language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a description of an image in human readable language with complete sentences.
-
#describe_image_with_http_info(url, max_candidates: '1', language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a description of an image in human readable language with complete sentences.
-
#generate_thumbnail(width, height, url, smart_cropping: false, custom_headers: nil) ⇒ NOT_IMPLEMENTED
This operation generates a thumbnail image with the user-specified width and height.
-
#generate_thumbnail_async(width, height, url, smart_cropping: false, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a thumbnail image with the user-specified width and height.
-
#generate_thumbnail_in_stream(width, height, image, smart_cropping: false, custom_headers: nil) ⇒ NOT_IMPLEMENTED
This operation generates a thumbnail image with the user-specified width and height.
-
#generate_thumbnail_in_stream_async(width, height, image, smart_cropping: false, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a thumbnail image with the user-specified width and height.
-
#generate_thumbnail_in_stream_with_http_info(width, height, image, smart_cropping: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a thumbnail image with the user-specified width and height.
-
#generate_thumbnail_with_http_info(width, height, url, smart_cropping: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a thumbnail image with the user-specified width and height.
-
#get_text_operation_result(operation_id, custom_headers: nil) ⇒ TextOperationResult
This interface is used for getting text operation result.
-
#get_text_operation_result_async(operation_id, custom_headers: nil) ⇒ Concurrent::Promise
This interface is used for getting text operation result.
-
#get_text_operation_result_with_http_info(operation_id, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This interface is used for getting text operation result.
-
#initialize(credentials = nil, options = nil) ⇒ ComputerVisionClient
constructor
Creates initializes a new instance of the ComputerVisionClient class.
-
#list_models(custom_headers: nil) ⇒ ListModelsResult
This operation returns the list of domain-specific models that are supported by the Computer Vision API.
-
#list_models_async(custom_headers: nil) ⇒ Concurrent::Promise
This operation returns the list of domain-specific models that are supported by the Computer Vision API.
-
#list_models_with_http_info(custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation returns the list of domain-specific models that are supported by the Computer Vision API.
-
#make_request(method, path, options = {}) ⇒ Hash{String=>String}
Makes a request and returns the body of the response.
-
#make_request_async(method, path, options = {}) ⇒ Concurrent::Promise
Makes a request asynchronously.
-
#make_request_with_http_info(method, path, options = {}) ⇒ MsRestAzure::AzureOperationResponse
Makes a request and returns the operation response.
-
#recognize_printed_text(detect_orientation, url, language: nil, custom_headers: nil) ⇒ OcrResult
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream.
-
#recognize_printed_text_async(detect_orientation, url, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream.
-
#recognize_printed_text_in_stream(detect_orientation, image, language: nil, custom_headers: nil) ⇒ OcrResult
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream.
-
#recognize_printed_text_in_stream_async(detect_orientation, image, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream.
-
#recognize_printed_text_in_stream_with_http_info(detect_orientation, image, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream.
-
#recognize_printed_text_with_http_info(detect_orientation, url, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream.
-
#recognize_text(url, detect_handwriting: false, custom_headers: nil) ⇒ Object
Recognize Text operation.
-
#recognize_text_async(url, detect_handwriting: false, custom_headers: nil) ⇒ Concurrent::Promise
Recognize Text operation.
-
#recognize_text_in_stream(image, detect_handwriting: false, custom_headers: nil) ⇒ Object
Recognize Text operation.
-
#recognize_text_in_stream_async(image, detect_handwriting: false, custom_headers: nil) ⇒ Concurrent::Promise
Recognize Text operation.
-
#recognize_text_in_stream_with_http_info(image, detect_handwriting: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Recognize Text operation.
-
#recognize_text_with_http_info(url, detect_handwriting: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Recognize Text operation.
-
#tag_image(url, language: nil, custom_headers: nil) ⇒ TagResult
This operation generates a list of words, or tags, that are relevant to the content of the supplied image.
-
#tag_image_async(url, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a list of words, or tags, that are relevant to the content of the supplied image.
-
#tag_image_in_stream(image, language: nil, custom_headers: nil) ⇒ TagResult
This operation generates a list of words, or tags, that are relevant to the content of the supplied image.
-
#tag_image_in_stream_async(image, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a list of words, or tags, that are relevant to the content of the supplied image.
-
#tag_image_in_stream_with_http_info(image, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a list of words, or tags, that are relevant to the content of the supplied image.
-
#tag_image_with_http_info(url, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a list of words, or tags, that are relevant to the content of the supplied image.
Constructor Details
#initialize(credentials = nil, options = nil) ⇒ ComputerVisionClient
Creates initializes a new instance of the ComputerVisionClient class.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 44 def initialize(credentials = nil, = nil) super(credentials, ) @base_url = 'https://{AzureRegion}.api.cognitive.microsoft.com/vision/v1.0' fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil? @credentials = credentials @accept_language = 'en-US' @long_running_operation_retry_timeout = 30 @generate_client_request_id = true add_telemetry end |
Instance Attribute Details
#accept_language ⇒ String
Returns The preferred language for the response.
28 29 30 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 28 def accept_language @accept_language end |
#azure_region ⇒ AzureRegions
endpoints. Possible values include: ‘westus’, ‘westeurope’, ‘southeastasia’, ‘eastus2’, ‘westcentralus’, ‘westus2’, ‘eastus’, ‘southcentralus’, ‘northeurope’, ‘eastasia’, ‘australiaeast’, ‘brazilsouth’, ‘canadacentral’, ‘centralindia’, ‘uksouth’, ‘japaneast’
25 26 27 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 25 def azure_region @azure_region end |
#base_url ⇒ String (readonly)
Returns the base URI of the service.
15 16 17 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 15 def base_url @base_url end |
#credentials ⇒ Object (readonly)
Returns Credentials needed for the client to connect to Azure.
18 19 20 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 18 def credentials @credentials end |
#generate_client_request_id ⇒ Boolean
generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.
37 38 39 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 37 def generate_client_request_id @generate_client_request_id end |
#long_running_operation_retry_timeout ⇒ Integer
Operations. Default value is 30.
32 33 34 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 32 def long_running_operation_retry_timeout @long_running_operation_retry_timeout end |
Instance Method Details
#analyze_image(url, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ ImageAnalysis
This operation extracts a rich set of visual features based on the image content. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL. Within your request, there is an optional parameter to allow you to choose which features to return. By default, image categories are returned in the response.
visual feature types to return. Multiple values should be comma-separated. Valid visual feature types include:Categories - categorizes image content according to a taxonomy defined in documentation. Tags - tags the image with a detailed list of words related to the image content. Description - describes the image content with a complete English sentence. Faces - detects if faces are present. If present, generate coordinates, gender and age. ImageType - detects if image is clipart or a line drawing. Color - determines the accent color, dominant color, and whether an image is black&white.Adult - detects if the image is pornographic in nature (depicts nudity or a sex act). Sexually suggestive content is also detected. details to return. Multiple values should be comma-separated. Valid visual feature types include:Celebrities - identifies celebrities if detected in the image. parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
244 245 246 247 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 244 def analyze_image(url, visual_features:nil, details:nil, language:nil, custom_headers:nil) response = analyze_image_async(url, visual_features:visual_features, details:details, language:language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#analyze_image_async(url, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation extracts a rich set of visual features based on the image content. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL. Within your request, there is an optional parameter to allow you to choose which features to return. By default, image categories are returned in the response.
visual feature types to return. Multiple values should be comma-separated. Valid visual feature types include:Categories - categorizes image content according to a taxonomy defined in documentation. Tags - tags the image with a detailed list of words related to the image content. Description - describes the image content with a complete English sentence. Faces - detects if faces are present. If present, generate coordinates, gender and age. ImageType - detects if image is clipart or a line drawing. Color - determines the accent color, dominant color, and whether an image is black&white.Adult - detects if the image is pornographic in nature (depicts nudity or a sex act). Sexually suggestive content is also detected. details to return. Multiple values should be comma-separated. Valid visual feature types include:Celebrities - identifies celebrities if detected in the image. parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ to the HTTP request.
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 319 def analyze_image_async(url, visual_features:nil, details:nil, language:nil, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'url is nil' if url.nil? image_url = ImageUrl.new unless url.nil? image_url.url = url end request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageUrl.mapper() request_content = self.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'analyze' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'visualFeatures' => visual_features.nil? ? nil : visual_features.join(','),'details' => details.nil? ? nil : details.join(','),'language' => language}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageAnalysis.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#analyze_image_by_domain(model, url, language: nil, custom_headers: nil) ⇒ DomainModelResults
This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
969 970 971 972 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 969 def analyze_image_by_domain(model, url, language:nil, custom_headers:nil) response = analyze_image_by_domain_async(model, url, language:language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#analyze_image_by_domain_async(model, url, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ to the HTTP request.
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1022 def analyze_image_by_domain_async(model, url, language:nil, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'model is nil' if model.nil? fail ArgumentError, 'url is nil' if url.nil? image_url = ImageUrl.new unless url.nil? image_url.url = url end request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageUrl.mapper() request_content = self.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'models/{model}/analyze' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'model' => model}, query_params: {'language' => language}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::DomainModelResults.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#analyze_image_by_domain_in_stream(model, image, language: nil, custom_headers: nil) ⇒ DomainModelResults
This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
2052 2053 2054 2055 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 2052 def analyze_image_by_domain_in_stream(model, image, language:nil, custom_headers:nil) response = analyze_image_by_domain_in_stream_async(model, image, language:language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#analyze_image_by_domain_in_stream_async(model, image, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ to the HTTP request.
2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 2105 def analyze_image_by_domain_in_stream_async(model, image, language:nil, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'model is nil' if model.nil? fail ArgumentError, 'image is nil' if image.nil? request_headers = {} request_headers['Content-Type'] = 'application/octet-stream' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'Image', type: { name: 'Stream' } } request_content = self.serialize(request_mapper, image) path_template = 'models/{model}/analyze' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'model' => model}, query_params: {'language' => language}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::DomainModelResults.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#analyze_image_by_domain_in_stream_with_http_info(model, image, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
2079 2080 2081 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 2079 def analyze_image_by_domain_in_stream_with_http_info(model, image, language:nil, custom_headers:nil) analyze_image_by_domain_in_stream_async(model, image, language:language, custom_headers:custom_headers).value! end |
#analyze_image_by_domain_with_http_info(model, url, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
996 997 998 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 996 def analyze_image_by_domain_with_http_info(model, url, language:nil, custom_headers:nil) analyze_image_by_domain_async(model, url, language:language, custom_headers:custom_headers).value! end |
#analyze_image_in_stream(image, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ ImageAnalysis
This operation extracts a rich set of visual features based on the image content.
visual feature types to return. Multiple values should be comma-separated. Valid visual feature types include:Categories - categorizes image content according to a taxonomy defined in documentation. Tags - tags the image with a detailed list of words related to the image content. Description - describes the image content with a complete English sentence. Faces - detects if faces are present. If present, generate coordinates, gender and age. ImageType - detects if image is clipart or a line drawing. Color - determines the accent color, dominant color, and whether an image is black&white.Adult - detects if the image is pornographic in nature (depicts nudity or a sex act). Sexually suggestive content is also detected. return. Multiple values should be comma-separated. Valid visual feature types include:Celebrities - identifies celebrities if detected in the image. Possible values include: ‘Celebrities’, ‘Landmarks’ parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
1323 1324 1325 1326 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1323 def analyze_image_in_stream(image, visual_features:nil, details:nil, language:nil, custom_headers:nil) response = analyze_image_in_stream_async(image, visual_features:visual_features, details:details, language:language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#analyze_image_in_stream_async(image, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation extracts a rich set of visual features based on the image content.
visual feature types to return. Multiple values should be comma-separated. Valid visual feature types include:Categories - categorizes image content according to a taxonomy defined in documentation. Tags - tags the image with a detailed list of words related to the image content. Description - describes the image content with a complete English sentence. Faces - detects if faces are present. If present, generate coordinates, gender and age. ImageType - detects if image is clipart or a line drawing. Color - determines the accent color, dominant color, and whether an image is black&white.Adult - detects if the image is pornographic in nature (depicts nudity or a sex act). Sexually suggestive content is also detected. return. Multiple values should be comma-separated. Valid visual feature types include:Celebrities - identifies celebrities if detected in the image. Possible values include: ‘Celebrities’, ‘Landmarks’ parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ to the HTTP request.
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1392 def analyze_image_in_stream_async(image, visual_features:nil, details:nil, language:nil, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'image is nil' if image.nil? request_headers = {} request_headers['Content-Type'] = 'application/octet-stream' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'Image', type: { name: 'Stream' } } request_content = self.serialize(request_mapper, image) path_template = 'analyze' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'visualFeatures' => visual_features.nil? ? nil : visual_features.join(','),'details' => details,'language' => language}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageAnalysis.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#analyze_image_in_stream_with_http_info(image, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation extracts a rich set of visual features based on the image content.
visual feature types to return. Multiple values should be comma-separated. Valid visual feature types include:Categories - categorizes image content according to a taxonomy defined in documentation. Tags - tags the image with a detailed list of words related to the image content. Description - describes the image content with a complete English sentence. Faces - detects if faces are present. If present, generate coordinates, gender and age. ImageType - detects if image is clipart or a line drawing. Color - determines the accent color, dominant color, and whether an image is black&white.Adult - detects if the image is pornographic in nature (depicts nudity or a sex act). Sexually suggestive content is also detected. return. Multiple values should be comma-separated. Valid visual feature types include:Celebrities - identifies celebrities if detected in the image. Possible values include: ‘Celebrities’, ‘Landmarks’ parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
1358 1359 1360 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1358 def analyze_image_in_stream_with_http_info(image, visual_features:nil, details:nil, language:nil, custom_headers:nil) analyze_image_in_stream_async(image, visual_features:visual_features, details:details, language:language, custom_headers:custom_headers).value! end |
#analyze_image_with_http_info(url, visual_features: nil, details: nil, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation extracts a rich set of visual features based on the image content. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL. Within your request, there is an optional parameter to allow you to choose which features to return. By default, image categories are returned in the response.
visual feature types to return. Multiple values should be comma-separated. Valid visual feature types include:Categories - categorizes image content according to a taxonomy defined in documentation. Tags - tags the image with a detailed list of words related to the image content. Description - describes the image content with a complete English sentence. Faces - detects if faces are present. If present, generate coordinates, gender and age. ImageType - detects if image is clipart or a line drawing. Color - determines the accent color, dominant color, and whether an image is black&white.Adult - detects if the image is pornographic in nature (depicts nudity or a sex act). Sexually suggestive content is also detected. details to return. Multiple values should be comma-separated. Valid visual feature types include:Celebrities - identifies celebrities if detected in the image. parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
282 283 284 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 282 def analyze_image_with_http_info(url, visual_features:nil, details:nil, language:nil, custom_headers:nil) analyze_image_async(url, visual_features:visual_features, details:details, language:language, custom_headers:custom_headers).value! end |
#describe_image(url, max_candidates: '1', language: nil, custom_headers: nil) ⇒ ImageDescription
This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. More than one description can be generated for each image. Descriptions are ordered by their confidence score. All descriptions are in English. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL.A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
returned. The default is 1. parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
695 696 697 698 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 695 def describe_image(url, max_candidates:'1', language:nil, custom_headers:nil) response = describe_image_async(url, max_candidates:max_candidates, language:language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#describe_image_async(url, max_candidates: '1', language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. More than one description can be generated for each image. Descriptions are ordered by their confidence score. All descriptions are in English. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL.A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
returned. The default is 1. parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ to the HTTP request.
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 750 def describe_image_async(url, max_candidates:'1', language:nil, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'url is nil' if url.nil? image_url = ImageUrl.new unless url.nil? image_url.url = url end request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageUrl.mapper() request_content = self.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'describe' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'maxCandidates' => max_candidates,'language' => language}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageDescription.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#describe_image_in_stream(image, max_candidates: '1', language: nil, custom_headers: nil) ⇒ ImageDescription
This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. More than one description can be generated for each image. Descriptions are ordered by their confidence score. All descriptions are in English. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL.A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
returned. The default is 1. parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
1774 1775 1776 1777 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1774 def describe_image_in_stream(image, max_candidates:'1', language:nil, custom_headers:nil) response = describe_image_in_stream_async(image, max_candidates:max_candidates, language:language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#describe_image_in_stream_async(image, max_candidates: '1', language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. More than one description can be generated for each image. Descriptions are ordered by their confidence score. All descriptions are in English. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL.A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
returned. The default is 1. parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ to the HTTP request.
1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1829 def describe_image_in_stream_async(image, max_candidates:'1', language:nil, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'image is nil' if image.nil? request_headers = {} request_headers['Content-Type'] = 'application/octet-stream' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'Image', type: { name: 'Stream' } } request_content = self.serialize(request_mapper, image) path_template = 'describe' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'maxCandidates' => max_candidates,'language' => language}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageDescription.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#describe_image_in_stream_with_http_info(image, max_candidates: '1', language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. More than one description can be generated for each image. Descriptions are ordered by their confidence score. All descriptions are in English. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL.A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
returned. The default is 1. parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
1802 1803 1804 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1802 def describe_image_in_stream_with_http_info(image, max_candidates:'1', language:nil, custom_headers:nil) describe_image_in_stream_async(image, max_candidates:max_candidates, language:language, custom_headers:custom_headers).value! end |
#describe_image_with_http_info(url, max_candidates: '1', language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. More than one description can be generated for each image. Descriptions are ordered by their confidence score. All descriptions are in English. Two input methods are supported – (1) Uploading an image or (2) specifying an image URL.A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
returned. The default is 1. parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
723 724 725 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 723 def describe_image_with_http_info(url, max_candidates:'1', language:nil, custom_headers:nil) describe_image_async(url, max_candidates:max_candidates, language:language, custom_headers:custom_headers).value! end |
#generate_thumbnail(width, height, url, smart_cropping: false, custom_headers: nil) ⇒ NOT_IMPLEMENTED
This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. Smart cropping helps when you specify an aspect ratio that differs from that of the input image. A successful response contains the thumbnail image binary. If the request failed, the response contains an error code and a message to help determine what went wrong.
Recommended minimum of 50.
-
Recommended minimum of 50.
will be added to the HTTP request.
403 404 405 406 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 403 def generate_thumbnail(width, height, url, smart_cropping:false, custom_headers:nil) response = generate_thumbnail_async(width, height, url, smart_cropping:smart_cropping, custom_headers:custom_headers).value! response.body unless response.nil? end |
#generate_thumbnail_async(width, height, url, smart_cropping: false, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. Smart cropping helps when you specify an aspect ratio that differs from that of the input image. A successful response contains the thumbnail image binary. If the request failed, the response contains an error code and a message to help determine what went wrong.
Recommended minimum of 50.
-
Recommended minimum of 50.
to the HTTP request.
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 452 def generate_thumbnail_async(width, height, url, smart_cropping:false, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'width is nil' if width.nil? fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMaximum': '1023'" if !width.nil? && width > 1023 fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMinimum': '1'" if !width.nil? && width < 1 fail ArgumentError, 'height is nil' if height.nil? fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMaximum': '1023'" if !height.nil? && height > 1023 fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMinimum': '1'" if !height.nil? && height < 1 fail ArgumentError, 'url is nil' if url.nil? image_url = ImageUrl.new unless url.nil? image_url.url = url end request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageUrl.mapper() request_content = self.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'generateThumbnail' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'width' => width,'height' => height,'smartCropping' => smart_cropping}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = { client_side_validation: true, required: false, serialized_name: 'parsed_response', type: { name: 'Stream' } } result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#generate_thumbnail_in_stream(width, height, image, smart_cropping: false, custom_headers: nil) ⇒ NOT_IMPLEMENTED
This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. Smart cropping helps when you specify an aspect ratio that differs from that of the input image. A successful response contains the thumbnail image binary. If the request failed, the response contains an error code and a message to help determine what went wrong.
Recommended minimum of 50.
-
Recommended minimum of 50.
will be added to the HTTP request.
1478 1479 1480 1481 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1478 def generate_thumbnail_in_stream(width, height, image, smart_cropping:false, custom_headers:nil) response = generate_thumbnail_in_stream_async(width, height, image, smart_cropping:smart_cropping, custom_headers:custom_headers).value! response.body unless response.nil? end |
#generate_thumbnail_in_stream_async(width, height, image, smart_cropping: false, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. Smart cropping helps when you specify an aspect ratio that differs from that of the input image. A successful response contains the thumbnail image binary. If the request failed, the response contains an error code and a message to help determine what went wrong.
Recommended minimum of 50.
-
Recommended minimum of 50.
to the HTTP request.
1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1527 def generate_thumbnail_in_stream_async(width, height, image, smart_cropping:false, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'width is nil' if width.nil? fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMaximum': '1023'" if !width.nil? && width > 1023 fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMinimum': '1'" if !width.nil? && width < 1 fail ArgumentError, 'height is nil' if height.nil? fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMaximum': '1023'" if !height.nil? && height > 1023 fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMinimum': '1'" if !height.nil? && height < 1 fail ArgumentError, 'image is nil' if image.nil? request_headers = {} request_headers['Content-Type'] = 'application/octet-stream' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'Image', type: { name: 'Stream' } } request_content = self.serialize(request_mapper, image) path_template = 'generateThumbnail' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'width' => width,'height' => height,'smartCropping' => smart_cropping}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = { client_side_validation: true, required: false, serialized_name: 'parsed_response', type: { name: 'Stream' } } result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#generate_thumbnail_in_stream_with_http_info(width, height, image, smart_cropping: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. Smart cropping helps when you specify an aspect ratio that differs from that of the input image. A successful response contains the thumbnail image binary. If the request failed, the response contains an error code and a message to help determine what went wrong.
Recommended minimum of 50.
-
Recommended minimum of 50.
will be added to the HTTP request.
1503 1504 1505 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1503 def generate_thumbnail_in_stream_with_http_info(width, height, image, smart_cropping:false, custom_headers:nil) generate_thumbnail_in_stream_async(width, height, image, smart_cropping:smart_cropping, custom_headers:custom_headers).value! end |
#generate_thumbnail_with_http_info(width, height, url, smart_cropping: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. Smart cropping helps when you specify an aspect ratio that differs from that of the input image. A successful response contains the thumbnail image binary. If the request failed, the response contains an error code and a message to help determine what went wrong.
Recommended minimum of 50.
-
Recommended minimum of 50.
will be added to the HTTP request.
428 429 430 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 428 def generate_thumbnail_with_http_info(width, height, url, smart_cropping:false, custom_headers:nil) generate_thumbnail_async(width, height, url, smart_cropping:smart_cropping, custom_headers:custom_headers).value! end |
#get_text_operation_result(operation_id, custom_headers: nil) ⇒ TextOperationResult
This interface is used for getting text operation result. The URL to this interface should be retrieved from ‘Operation-Location’ field returned from Recognize Text interface.
response of the ‘Recognize Handwritten Text’ will be added to the HTTP request.
1207 1208 1209 1210 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1207 def get_text_operation_result(operation_id, custom_headers:nil) response = get_text_operation_result_async(operation_id, custom_headers:custom_headers).value! response.body unless response.nil? end |
#get_text_operation_result_async(operation_id, custom_headers: nil) ⇒ Concurrent::Promise
This interface is used for getting text operation result. The URL to this interface should be retrieved from ‘Operation-Location’ field returned from Recognize Text interface.
response of the ‘Recognize Handwritten Text’ to the HTTP request.
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1240 def get_text_operation_result_async(operation_id, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'operation_id is nil' if operation_id.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? path_template = 'textOperations/{operationId}' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'operationId' => operation_id}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:get, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::TextOperationResult.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#get_text_operation_result_with_http_info(operation_id, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This interface is used for getting text operation result. The URL to this interface should be retrieved from ‘Operation-Location’ field returned from Recognize Text interface.
response of the ‘Recognize Handwritten Text’ will be added to the HTTP request.
1224 1225 1226 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1224 def get_text_operation_result_with_http_info(operation_id, custom_headers:nil) get_text_operation_result_async(operation_id, custom_headers:custom_headers).value! end |
#list_models(custom_headers: nil) ⇒ ListModelsResult
This operation returns the list of domain-specific models that are supported by the Computer Vision API. Currently, the API only supports one domain-specific model: a celebrity recognizer. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
will be added to the HTTP request.
127 128 129 130 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 127 def list_models(custom_headers:nil) response = list_models_async(custom_headers:custom_headers).value! response.body unless response.nil? end |
#list_models_async(custom_headers: nil) ⇒ Concurrent::Promise
This operation returns the list of domain-specific models that are supported by the Computer Vision API. Currently, the API only supports one domain-specific model: a celebrity recognizer. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
to the HTTP request.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 160 def list_models_async(custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? path_template = 'models' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:get, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ListModelsResult.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#list_models_with_http_info(custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation returns the list of domain-specific models that are supported by the Computer Vision API. Currently, the API only supports one domain-specific model: a celebrity recognizer. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
will be added to the HTTP request.
144 145 146 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 144 def list_models_with_http_info(custom_headers:nil) list_models_async(custom_headers:custom_headers).value! end |
#make_request(method, path, options = {}) ⇒ Hash{String=>String}
Makes a request and returns the body of the response. Example:
request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
path = "/path"
= {
body: request_content,
query_params: {'api-version' => '2016-02-01'}
}
result = @client.make_request(:put, path, )
73 74 75 76 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 73 def make_request(method, path, = {}) result = make_request_with_http_info(method, path, ) result.body unless result.nil? end |
#make_request_async(method, path, options = {}) ⇒ Concurrent::Promise
Makes a request asynchronously.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 98 def make_request_async(method, path, = {}) fail ArgumentError, 'method is nil' if method.nil? fail ArgumentError, 'path is nil' if path.nil? request_url = [:base_url] || @base_url if(![:headers].nil? && ![:headers]['Content-Type'].nil?) @request_headers['Content-Type'] = [:headers]['Content-Type'] end request_headers = @request_headers request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil? .merge!({headers: request_headers.merge([:headers] || {})}) .merge!({credentials: @credentials}) unless @credentials.nil? super(request_url, method, path, ) end |
#make_request_with_http_info(method, path, options = {}) ⇒ MsRestAzure::AzureOperationResponse
Makes a request and returns the operation response.
85 86 87 88 89 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 85 def make_request_with_http_info(method, path, = {}) result = make_request_async(method, path, ).value! result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body) result end |
#recognize_printed_text(detect_orientation, url, language: nil, custom_headers: nil) ⇒ OcrResult
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream. Upon success, the OCR results will be returned. Upon failure, the error code together with an error message will be returned. The error code can be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or InternalServerError.
the image. With detectOrientation=true the OCR service tries to detect the image orientation and correct it before further processing (e.g. if it’s upside-down). detected in the image. The default value is ‘unk’. Possible values include: ‘unk’, ‘zh-Hans’, ‘zh-Hant’, ‘cs’, ‘da’, ‘nl’, ‘en’, ‘fi’, ‘fr’, ‘de’, ‘el’, ‘hu’, ‘it’, ‘ja’, ‘ko’, ‘nb’, ‘pl’, ‘pt’, ‘ru’, ‘es’, ‘sv’, ‘tr’, ‘ar’, ‘ro’, ‘sr-Cyrl’, ‘sr-Latn’, ‘sk’ will be added to the HTTP request.
552 553 554 555 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 552 def recognize_printed_text(detect_orientation, url, language:nil, custom_headers:nil) response = recognize_printed_text_async(detect_orientation, url, language:language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#recognize_printed_text_async(detect_orientation, url, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream. Upon success, the OCR results will be returned. Upon failure, the error code together with an error message will be returned. The error code can be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or InternalServerError.
the image. With detectOrientation=true the OCR service tries to detect the image orientation and correct it before further processing (e.g. if it’s upside-down). detected in the image. The default value is ‘unk’. Possible values include: ‘unk’, ‘zh-Hans’, ‘zh-Hant’, ‘cs’, ‘da’, ‘nl’, ‘en’, ‘fi’, ‘fr’, ‘de’, ‘el’, ‘hu’, ‘it’, ‘ja’, ‘ko’, ‘nb’, ‘pl’, ‘pt’, ‘ru’, ‘es’, ‘sv’, ‘tr’, ‘ar’, ‘ro’, ‘sr-Cyrl’, ‘sr-Latn’, ‘sk’ to the HTTP request.
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 607 def recognize_printed_text_async(detect_orientation, url, language:nil, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'detect_orientation is nil' if detect_orientation.nil? fail ArgumentError, 'url is nil' if url.nil? image_url = ImageUrl.new unless url.nil? image_url.url = url end request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageUrl.mapper() request_content = self.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'ocr' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'detectOrientation' => detect_orientation,'language' => language}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::OcrResult.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#recognize_printed_text_in_stream(detect_orientation, image, language: nil, custom_headers: nil) ⇒ OcrResult
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream. Upon success, the OCR results will be returned. Upon failure, the error code together with an error message will be returned. The error code can be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or InternalServerError.
the image. With detectOrientation=true the OCR service tries to detect the image orientation and correct it before further processing (e.g. if it’s upside-down). detected in the image. The default value is ‘unk’. Possible values include: ‘unk’, ‘zh-Hans’, ‘zh-Hant’, ‘cs’, ‘da’, ‘nl’, ‘en’, ‘fi’, ‘fr’, ‘de’, ‘el’, ‘hu’, ‘it’, ‘ja’, ‘ko’, ‘nb’, ‘pl’, ‘pt’, ‘ru’, ‘es’, ‘sv’, ‘tr’, ‘ar’, ‘ro’, ‘sr-Cyrl’, ‘sr-Latn’, ‘sk’ will be added to the HTTP request.
1629 1630 1631 1632 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1629 def recognize_printed_text_in_stream(detect_orientation, image, language:nil, custom_headers:nil) response = recognize_printed_text_in_stream_async(detect_orientation, image, language:language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#recognize_printed_text_in_stream_async(detect_orientation, image, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream. Upon success, the OCR results will be returned. Upon failure, the error code together with an error message will be returned. The error code can be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or InternalServerError.
the image. With detectOrientation=true the OCR service tries to detect the image orientation and correct it before further processing (e.g. if it’s upside-down). detected in the image. The default value is ‘unk’. Possible values include: ‘unk’, ‘zh-Hans’, ‘zh-Hant’, ‘cs’, ‘da’, ‘nl’, ‘en’, ‘fi’, ‘fr’, ‘de’, ‘el’, ‘hu’, ‘it’, ‘ja’, ‘ko’, ‘nb’, ‘pl’, ‘pt’, ‘ru’, ‘es’, ‘sv’, ‘tr’, ‘ar’, ‘ro’, ‘sr-Cyrl’, ‘sr-Latn’, ‘sk’ to the HTTP request.
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1684 def recognize_printed_text_in_stream_async(detect_orientation, image, language:nil, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'detect_orientation is nil' if detect_orientation.nil? fail ArgumentError, 'image is nil' if image.nil? request_headers = {} request_headers['Content-Type'] = 'application/octet-stream' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'Image', type: { name: 'Stream' } } request_content = self.serialize(request_mapper, image) path_template = 'ocr' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'language' => language,'detectOrientation' => detect_orientation}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::OcrResult.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#recognize_printed_text_in_stream_with_http_info(detect_orientation, image, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream. Upon success, the OCR results will be returned. Upon failure, the error code together with an error message will be returned. The error code can be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or InternalServerError.
the image. With detectOrientation=true the OCR service tries to detect the image orientation and correct it before further processing (e.g. if it’s upside-down). detected in the image. The default value is ‘unk’. Possible values include: ‘unk’, ‘zh-Hans’, ‘zh-Hant’, ‘cs’, ‘da’, ‘nl’, ‘en’, ‘fi’, ‘fr’, ‘de’, ‘el’, ‘hu’, ‘it’, ‘ja’, ‘ko’, ‘nb’, ‘pl’, ‘pt’, ‘ru’, ‘es’, ‘sv’, ‘tr’, ‘ar’, ‘ro’, ‘sr-Cyrl’, ‘sr-Latn’, ‘sk’ will be added to the HTTP request.
1657 1658 1659 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1657 def recognize_printed_text_in_stream_with_http_info(detect_orientation, image, language:nil, custom_headers:nil) recognize_printed_text_in_stream_async(detect_orientation, image, language:language, custom_headers:custom_headers).value! end |
#recognize_printed_text_with_http_info(detect_orientation, url, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Optical Character Recognition (OCR) detects printed text in an image and extracts the recognized characters into a machine-usable character stream. Upon success, the OCR results will be returned. Upon failure, the error code together with an error message will be returned. The error code can be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or InternalServerError.
the image. With detectOrientation=true the OCR service tries to detect the image orientation and correct it before further processing (e.g. if it’s upside-down). detected in the image. The default value is ‘unk’. Possible values include: ‘unk’, ‘zh-Hans’, ‘zh-Hant’, ‘cs’, ‘da’, ‘nl’, ‘en’, ‘fi’, ‘fr’, ‘de’, ‘el’, ‘hu’, ‘it’, ‘ja’, ‘ko’, ‘nb’, ‘pl’, ‘pt’, ‘ru’, ‘es’, ‘sv’, ‘tr’, ‘ar’, ‘ro’, ‘sr-Cyrl’, ‘sr-Latn’, ‘sk’ will be added to the HTTP request.
580 581 582 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 580 def recognize_printed_text_with_http_info(detect_orientation, url, language:nil, custom_headers:nil) recognize_printed_text_async(detect_orientation, url, language:language, custom_headers:custom_headers).value! end |
#recognize_text(url, detect_handwriting: false, custom_headers: nil) ⇒ Object
Recognize Text operation. When you use the Recognize Text interface, the response contains a field called ‘Operation-Location’. The ‘Operation-Location’ field contains the URL that you must use for your Get Handwritten Text Operation Result operation.
recognition is performed. If this parameter is set to ‘false’ or is not specified, printed text recognition is performed. will be added to the HTTP request.
1102 1103 1104 1105 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1102 def recognize_text(url, detect_handwriting:false, custom_headers:nil) response = recognize_text_async(url, detect_handwriting:detect_handwriting, custom_headers:custom_headers).value! nil end |
#recognize_text_async(url, detect_handwriting: false, custom_headers: nil) ⇒ Concurrent::Promise
Recognize Text operation. When you use the Recognize Text interface, the response contains a field called ‘Operation-Location’. The ‘Operation-Location’ field contains the URL that you must use for your Get Handwritten Text Operation Result operation.
recognition is performed. If this parameter is set to ‘false’ or is not specified, printed text recognition is performed. to the HTTP request.
1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1141 def recognize_text_async(url, detect_handwriting:false, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'url is nil' if url.nil? image_url = ImageUrl.new unless url.nil? image_url.url = url end request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageUrl.mapper() request_content = self.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'recognizeText' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'detectHandwriting' => detect_handwriting}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 202 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? result end promise.execute end |
#recognize_text_in_stream(image, detect_handwriting: false, custom_headers: nil) ⇒ Object
Recognize Text operation. When you use the Recognize Text interface, the response contains a field called ‘Operation-Location’. The ‘Operation-Location’ field contains the URL that you must use for your Get Handwritten Text Operation Result operation.
recognition is performed. If this parameter is set to ‘false’ or is not specified, printed text recognition is performed. will be added to the HTTP request.
2187 2188 2189 2190 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 2187 def recognize_text_in_stream(image, detect_handwriting:false, custom_headers:nil) response = recognize_text_in_stream_async(image, detect_handwriting:detect_handwriting, custom_headers:custom_headers).value! nil end |
#recognize_text_in_stream_async(image, detect_handwriting: false, custom_headers: nil) ⇒ Concurrent::Promise
Recognize Text operation. When you use the Recognize Text interface, the response contains a field called ‘Operation-Location’. The ‘Operation-Location’ field contains the URL that you must use for your Get Handwritten Text Operation Result operation.
recognition is performed. If this parameter is set to ‘false’ or is not specified, printed text recognition is performed. to the HTTP request.
2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 2226 def recognize_text_in_stream_async(image, detect_handwriting:false, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'image is nil' if image.nil? request_headers = {} request_headers['Content-Type'] = 'application/octet-stream' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'Image', type: { name: 'Stream' } } request_content = self.serialize(request_mapper, image) path_template = 'recognizeText' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'detectHandwriting' => detect_handwriting}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 202 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? result end promise.execute end |
#recognize_text_in_stream_with_http_info(image, detect_handwriting: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Recognize Text operation. When you use the Recognize Text interface, the response contains a field called ‘Operation-Location’. The ‘Operation-Location’ field contains the URL that you must use for your Get Handwritten Text Operation Result operation.
recognition is performed. If this parameter is set to ‘false’ or is not specified, printed text recognition is performed. will be added to the HTTP request.
2207 2208 2209 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 2207 def recognize_text_in_stream_with_http_info(image, detect_handwriting:false, custom_headers:nil) recognize_text_in_stream_async(image, detect_handwriting:detect_handwriting, custom_headers:custom_headers).value! end |
#recognize_text_with_http_info(url, detect_handwriting: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Recognize Text operation. When you use the Recognize Text interface, the response contains a field called ‘Operation-Location’. The ‘Operation-Location’ field contains the URL that you must use for your Get Handwritten Text Operation Result operation.
recognition is performed. If this parameter is set to ‘false’ or is not specified, printed text recognition is performed. will be added to the HTTP request.
1122 1123 1124 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1122 def recognize_text_with_http_info(url, detect_handwriting:false, custom_headers:nil) recognize_text_async(url, detect_handwriting:detect_handwriting, custom_headers:custom_headers).value! end |
#tag_image(url, language: nil, custom_headers: nil) ⇒ TagResult
This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Computer Vision API can return tags based on objects, living beings, scenery or actions found in images. Unlike categories, tags are not organized according to a hierarchical classification system, but correspond to image content. Tags may contain hints to avoid ambiguity or provide context, for example the tag ‘cello’ may be accompanied by the hint ‘musical instrument’. All tags are in English.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
834 835 836 837 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 834 def tag_image(url, language:nil, custom_headers:nil) response = tag_image_async(url, language:language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#tag_image_async(url, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Computer Vision API can return tags based on objects, living beings, scenery or actions found in images. Unlike categories, tags are not organized according to a hierarchical classification system, but correspond to image content. Tags may contain hints to avoid ambiguity or provide context, for example the tag ‘cello’ may be accompanied by the hint ‘musical instrument’. All tags are in English.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ to the HTTP request.
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 883 def tag_image_async(url, language:nil, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'url is nil' if url.nil? image_url = ImageUrl.new unless url.nil? image_url.url = url end request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::ImageUrl.mapper() request_content = self.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'tag' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'language' => language}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::TagResult.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#tag_image_in_stream(image, language: nil, custom_headers: nil) ⇒ TagResult
This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Computer Vision API can return tags based on objects, living beings, scenery or actions found in images. Unlike categories, tags are not organized according to a hierarchical classification system, but correspond to image content. Tags may contain hints to avoid ambiguity or provide context, for example the tag ‘cello’ may be accompanied by the hint ‘musical instrument’. All tags are in English.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
1915 1916 1917 1918 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1915 def tag_image_in_stream(image, language:nil, custom_headers:nil) response = tag_image_in_stream_async(image, language:language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#tag_image_in_stream_async(image, language: nil, custom_headers: nil) ⇒ Concurrent::Promise
This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Computer Vision API can return tags based on objects, living beings, scenery or actions found in images. Unlike categories, tags are not organized according to a hierarchical classification system, but correspond to image content. Tags may contain hints to avoid ambiguity or provide context, for example the tag ‘cello’ may be accompanied by the hint ‘musical instrument’. All tags are in English.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ to the HTTP request.
1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1964 def tag_image_in_stream_async(image, language:nil, custom_headers:nil) fail ArgumentError, 'azure_region is nil' if azure_region.nil? fail ArgumentError, 'image is nil' if image.nil? request_headers = {} request_headers['Content-Type'] = 'application/octet-stream' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'Image', type: { name: 'Stream' } } request_content = self.serialize(request_mapper, image) path_template = 'tag' request_url = @base_url || self.base_url request_url = request_url.gsub('{AzureRegion}', azure_region) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'language' => language}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ComputerVision::V1_0::Models::TagResult.mapper() result.body = self.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#tag_image_in_stream_with_http_info(image, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Computer Vision API can return tags based on objects, living beings, scenery or actions found in images. Unlike categories, tags are not organized according to a hierarchical classification system, but correspond to image content. Tags may contain hints to avoid ambiguity or provide context, for example the tag ‘cello’ may be accompanied by the hint ‘musical instrument’. All tags are in English.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
1940 1941 1942 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 1940 def tag_image_in_stream_with_http_info(image, language:nil, custom_headers:nil) tag_image_in_stream_async(image, language:language, custom_headers:custom_headers).value! end |
#tag_image_with_http_info(url, language: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Computer Vision API can return tags based on objects, living beings, scenery or actions found in images. Unlike categories, tags are not organized according to a hierarchical classification system, but correspond to image content. Tags may contain hints to avoid ambiguity or provide context, for example the tag ‘cello’ may be accompanied by the hint ‘musical instrument’. All tags are in English.
parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: ‘en’, ‘es’, ‘ja’, ‘pt’, ‘zh’ will be added to the HTTP request.
859 860 861 |
# File 'lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb', line 859 def tag_image_with_http_info(url, language:nil, custom_headers:nil) tag_image_async(url, language:language, custom_headers:custom_headers).value! end |