Class: Azure::CognitiveServices::ContentModerator::V1_0::ImageModeration
- Inherits:
-
Object
- Object
- Azure::CognitiveServices::ContentModerator::V1_0::ImageModeration
- Includes:
- MsRestAzure
- Defined in:
- lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb
Overview
You use the API to scan your content as it is generated. Content Moderator then processes your content and sends the results along with relevant information either back to your systems or to the built-in review tool. You can use this information to take decisions e.g. take it down, send to human judge, etc.
When using the API, images need to have a minimum of 128 pixels and a maximum file size of 4MB. Text can be at most 1024 characters long. If the content passed to the text API or the image API exceeds the size limits, the API will return an error code that informs about the issue.
This API is currently available in:
-
West US - westus.api.cognitive.microsoft.com
-
East US 2 - eastus2.api.cognitive.microsoft.com
-
West Central US - westcentralus.api.cognitive.microsoft.com
-
West Europe - westeurope.api.cognitive.microsoft.com
-
Southeast Asia - southeastasia.api.cognitive.microsoft.com .
Instance Attribute Summary collapse
-
#client ⇒ ContentModeratorClient
readonly
Reference to the ContentModeratorClient.
Instance Method Summary collapse
-
#evaluate_file_input(image_stream, cache_image: nil, custom_headers: nil) ⇒ Evaluate
Returns probabilities of the image containing racy or adult content.
-
#evaluate_file_input_async(image_stream, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns probabilities of the image containing racy or adult content.
-
#evaluate_file_input_with_http_info(image_stream, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns probabilities of the image containing racy or adult content.
-
#evaluate_method(cache_image: nil, custom_headers: nil) ⇒ Evaluate
Returns probabilities of the image containing racy or adult content.
-
#evaluate_method_async(cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns probabilities of the image containing racy or adult content.
-
#evaluate_method_with_http_info(cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns probabilities of the image containing racy or adult content.
-
#evaluate_url_input(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ Evaluate
Returns probabilities of the image containing racy or adult content.
-
#evaluate_url_input_async(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns probabilities of the image containing racy or adult content.
-
#evaluate_url_input_with_http_info(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns probabilities of the image containing racy or adult content.
-
#find_faces(cache_image: nil, custom_headers: nil) ⇒ FoundFaces
Returns the list of faces found.
-
#find_faces_async(cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns the list of faces found.
-
#find_faces_file_input(image_stream, cache_image: nil, custom_headers: nil) ⇒ FoundFaces
Returns the list of faces found.
-
#find_faces_file_input_async(image_stream, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns the list of faces found.
-
#find_faces_file_input_with_http_info(image_stream, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns the list of faces found.
-
#find_faces_url_input(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ FoundFaces
Returns the list of faces found.
-
#find_faces_url_input_async(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns the list of faces found.
-
#find_faces_url_input_with_http_info(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns the list of faces found.
-
#find_faces_with_http_info(cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns the list of faces found.
-
#initialize(client) ⇒ ImageModeration
constructor
Creates and initializes a new instance of the ImageModeration class.
-
#match_file_input(image_stream, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MatchResponse
Fuzzily match an image against one of your custom Image Lists.
-
#match_file_input_async(image_stream, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Fuzzily match an image against one of your custom Image Lists.
-
#match_file_input_with_http_info(image_stream, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Fuzzily match an image against one of your custom Image Lists.
-
#match_method(list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MatchResponse
Fuzzily match an image against one of your custom Image Lists.
-
#match_method_async(list_id: nil, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Fuzzily match an image against one of your custom Image Lists.
-
#match_method_with_http_info(list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Fuzzily match an image against one of your custom Image Lists.
-
#match_url_input(content_type, image_url, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MatchResponse
Fuzzily match an image against one of your custom Image Lists.
-
#match_url_input_async(content_type, image_url, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Fuzzily match an image against one of your custom Image Lists.
-
#match_url_input_with_http_info(content_type, image_url, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Fuzzily match an image against one of your custom Image Lists.
-
#ocrfile_input(language, image_stream, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ OCR
Returns any text found in the image for the language specified.
-
#ocrfile_input_async(language, image_stream, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ Concurrent::Promise
Returns any text found in the image for the language specified.
-
#ocrfile_input_with_http_info(language, image_stream, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns any text found in the image for the language specified.
-
#ocrmethod(language, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ OCR
Returns any text found in the image for the language specified.
-
#ocrmethod_async(language, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ Concurrent::Promise
Returns any text found in the image for the language specified.
-
#ocrmethod_with_http_info(language, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns any text found in the image for the language specified.
-
#ocrurl_input(language, content_type, image_url, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ OCR
Returns any text found in the image for the language specified.
-
#ocrurl_input_async(language, content_type, image_url, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ Concurrent::Promise
Returns any text found in the image for the language specified.
-
#ocrurl_input_with_http_info(language, content_type, image_url, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns any text found in the image for the language specified.
Constructor Details
#initialize(client) ⇒ ImageModeration
Creates and initializes a new instance of the ImageModeration class.
35 36 37 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 35 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ ContentModeratorClient (readonly)
Returns reference to the ContentModeratorClient.
40 41 42 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 40 def client @client end |
Instance Method Details
#evaluate_file_input(image_stream, cache_image: nil, custom_headers: nil) ⇒ Evaluate
Returns probabilities of the image containing racy or adult content.
use; defaults to false if omitted. will be added to the HTTP request.
933 934 935 936 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 933 def evaluate_file_input(image_stream, cache_image:nil, custom_headers:nil) response = evaluate_file_input_async(image_stream, cache_image:cache_image, custom_headers:custom_headers).value! response.body unless response.nil? end |
#evaluate_file_input_async(image_stream, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns probabilities of the image containing racy or adult content.
use; defaults to false if omitted. to the HTTP request.
964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 964 def evaluate_file_input_async(image_stream, cache_image:nil, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil? fail ArgumentError, 'image_stream is nil' if image_stream.nil? request_headers = {} request_headers['Content-Type'] = 'image/gif' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'ImageStream', type: { name: 'Stream' } } request_content = @client.serialize(request_mapper, image_stream) path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Evaluate' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'CacheImage' => cache_image}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Evaluate.mapper() result.body = @client.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 |
#evaluate_file_input_with_http_info(image_stream, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns probabilities of the image containing racy or adult content.
use; defaults to false if omitted. will be added to the HTTP request.
949 950 951 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 949 def evaluate_file_input_with_http_info(image_stream, cache_image:nil, custom_headers:nil) evaluate_file_input_async(image_stream, cache_image:cache_image, custom_headers:custom_headers).value! end |
#evaluate_method(cache_image: nil, custom_headers: nil) ⇒ Evaluate
Returns probabilities of the image containing racy or adult content.
use; defaults to false if omitted. will be added to the HTTP request.
255 256 257 258 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 255 def evaluate_method(cache_image:nil, custom_headers:nil) response = evaluate_method_async(cache_image:cache_image, custom_headers:custom_headers).value! response.body unless response.nil? end |
#evaluate_method_async(cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns probabilities of the image containing racy or adult content.
use; defaults to false if omitted. to the HTTP request.
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 284 def evaluate_method_async(cache_image:nil, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.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'] = @client.accept_language unless @client.accept_language.nil? path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Evaluate' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'CacheImage' => cache_image}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Evaluate.mapper() result.body = @client.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 |
#evaluate_method_with_http_info(cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns probabilities of the image containing racy or adult content.
use; defaults to false if omitted. will be added to the HTTP request.
270 271 272 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 270 def evaluate_method_with_http_info(cache_image:nil, custom_headers:nil) evaluate_method_async(cache_image:cache_image, custom_headers:custom_headers).value! end |
#evaluate_url_input(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ Evaluate
Returns probabilities of the image containing racy or adult content.
use; defaults to false if omitted. will be added to the HTTP request.
1040 1041 1042 1043 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 1040 def evaluate_url_input(content_type, image_url, cache_image:nil, custom_headers:nil) response = evaluate_url_input_async(content_type, image_url, cache_image:cache_image, custom_headers:custom_headers).value! response.body unless response.nil? end |
#evaluate_url_input_async(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns probabilities of the image containing racy or adult content.
use; defaults to false if omitted. to the HTTP request.
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 1073 def evaluate_url_input_async(content_type, image_url, cache_image:nil, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil? fail ArgumentError, 'content_type is nil' if content_type.nil? fail ArgumentError, 'image_url is nil' if image_url.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['Content-Type'] = content_type unless content_type.nil? request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageUrl.mapper() request_content = @client.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Evaluate' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'CacheImage' => cache_image}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Evaluate.mapper() result.body = @client.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 |
#evaluate_url_input_with_http_info(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns probabilities of the image containing racy or adult content.
use; defaults to false if omitted. will be added to the HTTP request.
1057 1058 1059 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 1057 def evaluate_url_input_with_http_info(content_type, image_url, cache_image:nil, custom_headers:nil) evaluate_url_input_async(content_type, image_url, cache_image:cache_image, custom_headers:custom_headers).value! end |
#find_faces(cache_image: nil, custom_headers: nil) ⇒ FoundFaces
Returns the list of faces found.
use; defaults to false if omitted. will be added to the HTTP request.
52 53 54 55 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 52 def find_faces(cache_image:nil, custom_headers:nil) response = find_faces_async(cache_image:cache_image, custom_headers:custom_headers).value! response.body unless response.nil? end |
#find_faces_async(cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns the list of faces found.
use; defaults to false if omitted. to the HTTP request.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 81 def find_faces_async(cache_image:nil, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.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'] = @client.accept_language unless @client.accept_language.nil? path_template = 'contentmoderator/moderate/v1.0/ProcessImage/FindFaces' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'CacheImage' => cache_image}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::FoundFaces.mapper() result.body = @client.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 |
#find_faces_file_input(image_stream, cache_image: nil, custom_headers: nil) ⇒ FoundFaces
Returns the list of faces found.
use; defaults to false if omitted. will be added to the HTTP request.
461 462 463 464 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 461 def find_faces_file_input(image_stream, cache_image:nil, custom_headers:nil) response = find_faces_file_input_async(image_stream, cache_image:cache_image, custom_headers:custom_headers).value! response.body unless response.nil? end |
#find_faces_file_input_async(image_stream, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns the list of faces found.
use; defaults to false if omitted. to the HTTP request.
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 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 492 def find_faces_file_input_async(image_stream, cache_image:nil, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil? fail ArgumentError, 'image_stream is nil' if image_stream.nil? request_headers = {} request_headers['Content-Type'] = 'image/gif' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'ImageStream', type: { name: 'Stream' } } request_content = @client.serialize(request_mapper, image_stream) path_template = 'contentmoderator/moderate/v1.0/ProcessImage/FindFaces' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'CacheImage' => cache_image}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::FoundFaces.mapper() result.body = @client.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 |
#find_faces_file_input_with_http_info(image_stream, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns the list of faces found.
use; defaults to false if omitted. will be added to the HTTP request.
477 478 479 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 477 def find_faces_file_input_with_http_info(image_stream, cache_image:nil, custom_headers:nil) find_faces_file_input_async(image_stream, cache_image:cache_image, custom_headers:custom_headers).value! end |
#find_faces_url_input(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ FoundFaces
Returns the list of faces found.
use; defaults to false if omitted. will be added to the HTTP request.
568 569 570 571 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 568 def find_faces_url_input(content_type, image_url, cache_image:nil, custom_headers:nil) response = find_faces_url_input_async(content_type, image_url, cache_image:cache_image, custom_headers:custom_headers).value! response.body unless response.nil? end |
#find_faces_url_input_async(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Returns the list of faces found.
use; defaults to false if omitted. to the HTTP request.
601 602 603 604 605 606 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 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 601 def find_faces_url_input_async(content_type, image_url, cache_image:nil, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil? fail ArgumentError, 'content_type is nil' if content_type.nil? fail ArgumentError, 'image_url is nil' if image_url.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['Content-Type'] = content_type unless content_type.nil? request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageUrl.mapper() request_content = @client.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'contentmoderator/moderate/v1.0/ProcessImage/FindFaces' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'CacheImage' => cache_image}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::FoundFaces.mapper() result.body = @client.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 |
#find_faces_url_input_with_http_info(content_type, image_url, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns the list of faces found.
use; defaults to false if omitted. will be added to the HTTP request.
585 586 587 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 585 def find_faces_url_input_with_http_info(content_type, image_url, cache_image:nil, custom_headers:nil) find_faces_url_input_async(content_type, image_url, cache_image:cache_image, custom_headers:custom_headers).value! end |
#find_faces_with_http_info(cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns the list of faces found.
use; defaults to false if omitted. will be added to the HTTP request.
67 68 69 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 67 def find_faces_with_http_info(cache_image:nil, custom_headers:nil) find_faces_async(cache_image:cache_image, custom_headers:custom_headers).value! end |
#match_file_input(image_stream, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MatchResponse
Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href=“/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe”>this</a> API.
Returns ID and tags of matching image.<br/> <br/> Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
use; defaults to false if omitted. will be added to the HTTP request.
1285 1286 1287 1288 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 1285 def match_file_input(image_stream, list_id:nil, cache_image:nil, custom_headers:nil) response = match_file_input_async(image_stream, list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value! response.body unless response.nil? end |
#match_file_input_async(image_stream, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href=“/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe”>this</a> API.
Returns ID and tags of matching image.<br/> <br/> Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
use; defaults to false if omitted. to the HTTP request.
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 1334 def match_file_input_async(image_stream, list_id:nil, cache_image:nil, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil? fail ArgumentError, 'image_stream is nil' if image_stream.nil? request_headers = {} request_headers['Content-Type'] = 'image/gif' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'ImageStream', type: { name: 'Stream' } } request_content = @client.serialize(request_mapper, image_stream) path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Match' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'listId' => list_id,'CacheImage' => cache_image}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::MatchResponse.mapper() result.body = @client.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 |
#match_file_input_with_http_info(image_stream, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href=“/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe”>this</a> API.
Returns ID and tags of matching image.<br/> <br/> Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
use; defaults to false if omitted. will be added to the HTTP request.
1310 1311 1312 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 1310 def match_file_input_with_http_info(image_stream, list_id:nil, cache_image:nil, custom_headers:nil) match_file_input_async(image_stream, list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value! end |
#match_method(list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MatchResponse
Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href=“/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe”>this</a> API.
Returns ID and tags of matching image.<br/> <br/> Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
use; defaults to false if omitted. will be added to the HTTP request.
353 354 355 356 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 353 def match_method(list_id:nil, cache_image:nil, custom_headers:nil) response = match_method_async(list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value! response.body unless response.nil? end |
#match_method_async(list_id: nil, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href=“/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe”>this</a> API.
Returns ID and tags of matching image.<br/> <br/> Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
use; defaults to false if omitted. to the HTTP request.
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 400 def match_method_async(list_id:nil, cache_image:nil, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.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'] = @client.accept_language unless @client.accept_language.nil? path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Match' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'listId' => list_id,'CacheImage' => cache_image}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::MatchResponse.mapper() result.body = @client.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 |
#match_method_with_http_info(list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href=“/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe”>this</a> API.
Returns ID and tags of matching image.<br/> <br/> Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
use; defaults to false if omitted. will be added to the HTTP request.
377 378 379 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 377 def match_method_with_http_info(list_id:nil, cache_image:nil, custom_headers:nil) match_method_async(list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value! end |
#match_url_input(content_type, image_url, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MatchResponse
Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href=“/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe”>this</a> API.
Returns ID and tags of matching image.<br/> <br/> Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
use; defaults to false if omitted. will be added to the HTTP request.
1154 1155 1156 1157 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 1154 def match_url_input(content_type, image_url, list_id:nil, cache_image:nil, custom_headers:nil) response = match_url_input_async(content_type, image_url, list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value! response.body unless response.nil? end |
#match_url_input_async(content_type, image_url, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ Concurrent::Promise
Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href=“/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe”>this</a> API.
Returns ID and tags of matching image.<br/> <br/> Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
use; defaults to false if omitted. to the HTTP request.
1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 1205 def match_url_input_async(content_type, image_url, list_id:nil, cache_image:nil, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil? fail ArgumentError, 'content_type is nil' if content_type.nil? fail ArgumentError, 'image_url is nil' if image_url.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['Content-Type'] = content_type unless content_type.nil? request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageUrl.mapper() request_content = @client.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Match' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'listId' => list_id,'CacheImage' => cache_image}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::MatchResponse.mapper() result.body = @client.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 |
#match_url_input_with_http_info(content_type, image_url, list_id: nil, cache_image: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href=“/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe”>this</a> API.
Returns ID and tags of matching image.<br/> <br/> Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
use; defaults to false if omitted. will be added to the HTTP request.
1180 1181 1182 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 1180 def match_url_input_with_http_info(content_type, image_url, list_id:nil, cache_image:nil, custom_headers:nil) match_url_input_async(content_type, image_url, list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value! end |
#ocrfile_input(language, image_stream, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ OCR
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
use; defaults to false if omitted. processing to come with additional candidates.
image/tiff is not supported when enhanced is set to true
Note: This impacts the response time. will be added to the HTTP request.
810 811 812 813 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 810 def ocrfile_input(language, image_stream, cache_image:nil, enhanced:false, custom_headers:nil) response = ocrfile_input_async(language, image_stream, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value! response.body unless response.nil? end |
#ocrfile_input_async(language, image_stream, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ Concurrent::Promise
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
use; defaults to false if omitted. processing to come with additional candidates.
image/tiff is not supported when enhanced is set to true
Note: This impacts the response time. to the HTTP request.
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 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 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 857 def ocrfile_input_async(language, image_stream, cache_image:nil, enhanced:false, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil? fail ArgumentError, 'language is nil' if language.nil? fail ArgumentError, 'image_stream is nil' if image_stream.nil? request_headers = {} request_headers['Content-Type'] = 'image/gif' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = { client_side_validation: true, required: true, serialized_name: 'ImageStream', type: { name: 'Stream' } } request_content = @client.serialize(request_mapper, image_stream) path_template = 'contentmoderator/moderate/v1.0/ProcessImage/OCR' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'language' => language,'CacheImage' => cache_image,'enhanced' => enhanced}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::OCR.mapper() result.body = @client.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 |
#ocrfile_input_with_http_info(language, image_stream, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
use; defaults to false if omitted. processing to come with additional candidates.
image/tiff is not supported when enhanced is set to true
Note: This impacts the response time. will be added to the HTTP request.
834 835 836 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 834 def ocrfile_input_with_http_info(language, image_stream, cache_image:nil, enhanced:false, custom_headers:nil) ocrfile_input_async(language, image_stream, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value! end |
#ocrmethod(language, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ OCR
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
use; defaults to false if omitted. processing to come with additional candidates.
image/tiff is not supported when enhanced is set to true
Note: This impacts the response time. will be added to the HTTP request.
149 150 151 152 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 149 def ocrmethod(language, cache_image:nil, enhanced:false, custom_headers:nil) response = ocrmethod_async(language, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value! response.body unless response.nil? end |
#ocrmethod_async(language, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ Concurrent::Promise
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
use; defaults to false if omitted. processing to come with additional candidates.
image/tiff is not supported when enhanced is set to true
Note: This impacts the response time. to the HTTP request.
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 194 def ocrmethod_async(language, cache_image:nil, enhanced:false, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil? fail ArgumentError, 'language is nil' if language.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'] = @client.accept_language unless @client.accept_language.nil? path_template = 'contentmoderator/moderate/v1.0/ProcessImage/OCR' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'language' => language,'CacheImage' => cache_image,'enhanced' => enhanced}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::OCR.mapper() result.body = @client.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 |
#ocrmethod_with_http_info(language, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
use; defaults to false if omitted. processing to come with additional candidates.
image/tiff is not supported when enhanced is set to true
Note: This impacts the response time. will be added to the HTTP request.
172 173 174 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 172 def ocrmethod_with_http_info(language, cache_image:nil, enhanced:false, custom_headers:nil) ocrmethod_async(language, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value! end |
#ocrurl_input(language, content_type, image_url, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ OCR
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
use; defaults to false if omitted. processing to come with additional candidates.
image/tiff is not supported when enhanced is set to true
Note: This impacts the response time. will be added to the HTTP request.
681 682 683 684 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 681 def ocrurl_input(language, content_type, image_url, cache_image:nil, enhanced:false, custom_headers:nil) response = ocrurl_input_async(language, content_type, image_url, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value! response.body unless response.nil? end |
#ocrurl_input_async(language, content_type, image_url, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ Concurrent::Promise
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
use; defaults to false if omitted. processing to come with additional candidates.
image/tiff is not supported when enhanced is set to true
Note: This impacts the response time. to the HTTP request.
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 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 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 730 def ocrurl_input_async(language, content_type, image_url, cache_image:nil, enhanced:false, custom_headers:nil) fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil? fail ArgumentError, 'language is nil' if language.nil? fail ArgumentError, 'content_type is nil' if content_type.nil? fail ArgumentError, 'image_url is nil' if image_url.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['Content-Type'] = content_type unless content_type.nil? request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageUrl.mapper() request_content = @client.serialize(request_mapper, image_url) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'contentmoderator/moderate/v1.0/ProcessImage/OCR' request_url = @base_url || @client.base_url request_url = request_url.gsub('{baseUrl}', @client.base_url) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'language' => language,'CacheImage' => cache_image,'enhanced' => enhanced}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::OCR.mapper() result.body = @client.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 |
#ocrurl_input_with_http_info(language, content_type, image_url, cache_image: nil, enhanced: false, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
use; defaults to false if omitted. processing to come with additional candidates.
image/tiff is not supported when enhanced is set to true
Note: This impacts the response time. will be added to the HTTP request.
706 707 708 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb', line 706 def ocrurl_input_with_http_info(language, content_type, image_url, cache_image:nil, enhanced:false, custom_headers:nil) ocrurl_input_async(language, content_type, image_url, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value! end |