azure_cognitiveservices_computervision 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/1.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb +1 -1
- data/lib/2.0/generated/azure_cognitiveservices_computervision.rb +30 -26
- data/lib/2.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb +1229 -627
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/adult_info.rb +3 -3
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/area_of_interest_result.rb +72 -0
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/bounding_rect.rb +83 -0
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/category.rb +1 -1
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/celebrities_model.rb +3 -2
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/celebrity_results.rb +3 -2
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/computer_vision_error.rb +3 -9
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/detect_result.rb +79 -0
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/detected_object.rb +86 -0
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/domain_model_results.rb +1 -1
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/face_description.rb +2 -1
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/face_rectangle.rb +8 -4
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/image_analysis.rb +30 -5
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/image_caption.rb +2 -2
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/image_metadata.rb +4 -4
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/image_tag.rb +4 -4
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/image_type.rb +4 -4
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/image_url.rb +1 -1
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/landmark_results.rb +3 -2
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/landmarks_model.rb +3 -2
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/model_description.rb +2 -2
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/object_hierarchy.rb +73 -0
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/ocr_region.rb +1 -1
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/ocr_result.rb +3 -3
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/visual_feature_types.rb +1 -0
- data/lib/profiles/latest/modules/computervision_profile_module.rb +99 -83
- data/lib/version.rb +1 -1
- metadata +7 -3
- data/lib/2.0/generated/azure_cognitiveservices_computervision/models/computer_vision_error_codes.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef1ae83a62f776e1479b5b977e117445ceef7808
|
4
|
+
data.tar.gz: 16abda3e423a0d11e4e04a7729a9d42bc47d03d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a4e89504d8d31f761e9333d2992b27bef4569c27a76978af9540d65209b8f0f9b32d60ef7ddb9a48c30cd404ab92af1d616325faf86db10183ecaef2216cfca
|
7
|
+
data.tar.gz: 87906ee6215eaf491b541369ba0d1b320e21789c5fdb2a9d165bbc31ee8424e18d12212cdff6b6056fe8f5caedd66b5c992ab4453ce14be5ab986ea8ca14b05f
|
@@ -2254,7 +2254,7 @@ module Azure::CognitiveServices::ComputerVision::V1_0
|
|
2254
2254
|
#
|
2255
2255
|
def add_telemetry
|
2256
2256
|
sdk_information = 'azure_cognitiveservices_computervision'
|
2257
|
-
sdk_information = "#{sdk_information}/0.
|
2257
|
+
sdk_information = "#{sdk_information}/0.18.0"
|
2258
2258
|
add_user_agent_information(sdk_information)
|
2259
2259
|
end
|
2260
2260
|
end
|
@@ -23,42 +23,46 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
23
23
|
autoload :ComputerVisionClient, '2.0/generated/azure_cognitiveservices_computervision/computer_vision_client.rb'
|
24
24
|
|
25
25
|
module Models
|
26
|
-
autoload :
|
27
|
-
autoload :
|
28
|
-
autoload :
|
29
|
-
autoload :
|
30
|
-
autoload :
|
26
|
+
autoload :DetectResult, '2.0/generated/azure_cognitiveservices_computervision/models/detect_result.rb'
|
27
|
+
autoload :FaceRectangle, '2.0/generated/azure_cognitiveservices_computervision/models/face_rectangle.rb'
|
28
|
+
autoload :ModelDescription, '2.0/generated/azure_cognitiveservices_computervision/models/model_description.rb'
|
29
|
+
autoload :LandmarksModel, '2.0/generated/azure_cognitiveservices_computervision/models/landmarks_model.rb'
|
30
|
+
autoload :ListModelsResult, '2.0/generated/azure_cognitiveservices_computervision/models/list_models_result.rb'
|
31
|
+
autoload :Category, '2.0/generated/azure_cognitiveservices_computervision/models/category.rb'
|
32
|
+
autoload :DomainModelResults, '2.0/generated/azure_cognitiveservices_computervision/models/domain_model_results.rb'
|
33
|
+
autoload :ColorInfo, '2.0/generated/azure_cognitiveservices_computervision/models/color_info.rb'
|
31
34
|
autoload :OcrWord, '2.0/generated/azure_cognitiveservices_computervision/models/ocr_word.rb'
|
32
|
-
autoload :
|
35
|
+
autoload :ImageTag, '2.0/generated/azure_cognitiveservices_computervision/models/image_tag.rb'
|
33
36
|
autoload :OcrLine, '2.0/generated/azure_cognitiveservices_computervision/models/ocr_line.rb'
|
34
|
-
autoload :
|
37
|
+
autoload :ImageDescriptionDetails, '2.0/generated/azure_cognitiveservices_computervision/models/image_description_details.rb'
|
35
38
|
autoload :OcrRegion, '2.0/generated/azure_cognitiveservices_computervision/models/ocr_region.rb'
|
36
|
-
autoload :
|
39
|
+
autoload :BoundingRect, '2.0/generated/azure_cognitiveservices_computervision/models/bounding_rect.rb'
|
37
40
|
autoload :OcrResult, '2.0/generated/azure_cognitiveservices_computervision/models/ocr_result.rb'
|
38
|
-
autoload :
|
39
|
-
autoload :
|
41
|
+
autoload :DetectedObject, '2.0/generated/azure_cognitiveservices_computervision/models/detected_object.rb'
|
42
|
+
autoload :TagResult, '2.0/generated/azure_cognitiveservices_computervision/models/tag_result.rb'
|
43
|
+
autoload :ImageAnalysis, '2.0/generated/azure_cognitiveservices_computervision/models/image_analysis.rb'
|
44
|
+
autoload :AreaOfInterestResult, '2.0/generated/azure_cognitiveservices_computervision/models/area_of_interest_result.rb'
|
45
|
+
autoload :CelebritiesModel, '2.0/generated/azure_cognitiveservices_computervision/models/celebrities_model.rb'
|
46
|
+
autoload :ImageUrl, '2.0/generated/azure_cognitiveservices_computervision/models/image_url.rb'
|
47
|
+
autoload :AdultInfo, '2.0/generated/azure_cognitiveservices_computervision/models/adult_info.rb'
|
48
|
+
autoload :ComputerVisionError, '2.0/generated/azure_cognitiveservices_computervision/models/computer_vision_error.rb'
|
40
49
|
autoload :ImageCaption, '2.0/generated/azure_cognitiveservices_computervision/models/image_caption.rb'
|
41
|
-
autoload :ListModelsResult, '2.0/generated/azure_cognitiveservices_computervision/models/list_models_result.rb'
|
42
|
-
autoload :Word, '2.0/generated/azure_cognitiveservices_computervision/models/word.rb'
|
43
|
-
autoload :DomainModelResults, '2.0/generated/azure_cognitiveservices_computervision/models/domain_model_results.rb'
|
44
|
-
autoload :FaceRectangle, '2.0/generated/azure_cognitiveservices_computervision/models/face_rectangle.rb'
|
45
|
-
autoload :CelebrityResults, '2.0/generated/azure_cognitiveservices_computervision/models/celebrity_results.rb'
|
46
|
-
autoload :Category, '2.0/generated/azure_cognitiveservices_computervision/models/category.rb'
|
47
50
|
autoload :LandmarkResults, '2.0/generated/azure_cognitiveservices_computervision/models/landmark_results.rb'
|
48
|
-
autoload :
|
51
|
+
autoload :ObjectHierarchy, '2.0/generated/azure_cognitiveservices_computervision/models/object_hierarchy.rb'
|
52
|
+
autoload :CelebrityResults, '2.0/generated/azure_cognitiveservices_computervision/models/celebrity_results.rb'
|
49
53
|
autoload :ImageDescription, '2.0/generated/azure_cognitiveservices_computervision/models/image_description.rb'
|
54
|
+
autoload :Word, '2.0/generated/azure_cognitiveservices_computervision/models/word.rb'
|
55
|
+
autoload :ImageType, '2.0/generated/azure_cognitiveservices_computervision/models/image_type.rb'
|
56
|
+
autoload :Line, '2.0/generated/azure_cognitiveservices_computervision/models/line.rb'
|
57
|
+
autoload :ImageMetadata, '2.0/generated/azure_cognitiveservices_computervision/models/image_metadata.rb'
|
50
58
|
autoload :RecognitionResult, '2.0/generated/azure_cognitiveservices_computervision/models/recognition_result.rb'
|
51
|
-
autoload :
|
52
|
-
autoload :
|
53
|
-
autoload :
|
54
|
-
autoload :LandmarksModel, '2.0/generated/azure_cognitiveservices_computervision/models/landmarks_model.rb'
|
55
|
-
autoload :ImageUrl, '2.0/generated/azure_cognitiveservices_computervision/models/image_url.rb'
|
56
|
-
autoload :ImageDescriptionDetails, '2.0/generated/azure_cognitiveservices_computervision/models/image_description_details.rb'
|
57
|
-
autoload :TextOperationStatusCodes, '2.0/generated/azure_cognitiveservices_computervision/models/text_operation_status_codes.rb'
|
59
|
+
autoload :FaceDescription, '2.0/generated/azure_cognitiveservices_computervision/models/face_description.rb'
|
60
|
+
autoload :TextOperationResult, '2.0/generated/azure_cognitiveservices_computervision/models/text_operation_result.rb'
|
61
|
+
autoload :CategoryDetail, '2.0/generated/azure_cognitiveservices_computervision/models/category_detail.rb'
|
58
62
|
autoload :Gender, '2.0/generated/azure_cognitiveservices_computervision/models/gender.rb'
|
59
|
-
autoload :
|
60
|
-
autoload :VisualFeatureTypes, '2.0/generated/azure_cognitiveservices_computervision/models/visual_feature_types.rb'
|
63
|
+
autoload :TextOperationStatusCodes, '2.0/generated/azure_cognitiveservices_computervision/models/text_operation_status_codes.rb'
|
61
64
|
autoload :OcrLanguages, '2.0/generated/azure_cognitiveservices_computervision/models/ocr_languages.rb'
|
65
|
+
autoload :VisualFeatureTypes, '2.0/generated/azure_cognitiveservices_computervision/models/visual_feature_types.rb'
|
62
66
|
autoload :TextRecognitionMode, '2.0/generated/azure_cognitiveservices_computervision/models/text_recognition_mode.rb'
|
63
67
|
autoload :Details, '2.0/generated/azure_cognitiveservices_computervision/models/details.rb'
|
64
68
|
end
|
@@ -17,7 +17,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
17
17
|
# @return Credentials needed for the client to connect to Azure.
|
18
18
|
attr_reader :credentials1
|
19
19
|
|
20
|
-
# @return [String] Supported Cognitive Services endpoints
|
20
|
+
# @return [String] Supported Cognitive Services endpoints.
|
21
21
|
attr_accessor :endpoint
|
22
22
|
|
23
23
|
# @return Subscription credentials which uniquely identify client
|
@@ -113,53 +113,139 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
113
113
|
end
|
114
114
|
|
115
115
|
#
|
116
|
-
# This operation
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#
|
116
|
+
# This operation extracts a rich set of visual features based on the image
|
117
|
+
# content.
|
118
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
119
|
+
# an image URL. Within your request, there is an optional parameter to allow
|
120
|
+
# you to choose which features to return. By default, image categories are
|
121
|
+
# returned in the response.
|
122
|
+
# A successful response will be returned in JSON. If the request failed, the
|
123
|
+
# response will contain an error code and a message to help understand what
|
124
|
+
# went wrong.
|
125
|
+
#
|
126
|
+
# @param url [String] Publicly reachable URL of an image.
|
127
|
+
# @param visual_features [Array<VisualFeatureTypes>] A string indicating what
|
128
|
+
# visual feature types to return. Multiple values should be comma-separated.
|
129
|
+
# Valid visual feature types include: Categories - categorizes image content
|
130
|
+
# according to a taxonomy defined in documentation. Tags - tags the image with
|
131
|
+
# a detailed list of words related to the image content. Description -
|
132
|
+
# describes the image content with a complete English sentence. Faces - detects
|
133
|
+
# if faces are present. If present, generate coordinates, gender and age.
|
134
|
+
# ImageType - detects if image is clipart or a line drawing. Color - determines
|
135
|
+
# the accent color, dominant color, and whether an image is black&white. Adult
|
136
|
+
# - detects if the image is pornographic in nature (depicts nudity or a sex
|
137
|
+
# act). Sexually suggestive content is also detected. Objects - detects
|
138
|
+
# various objects within an image, including the approximate location. The
|
139
|
+
# Objects argument is only available in English.
|
140
|
+
# @param details [Array<Details>] A string indicating which domain-specific
|
141
|
+
# details to return. Multiple values should be comma-separated. Valid visual
|
142
|
+
# feature types include: Celebrities - identifies celebrities if detected in
|
143
|
+
# the image, Landmarks - identifies notable landmarks in the image.
|
144
|
+
# @param language [Enum] The desired language for output generation. If this
|
145
|
+
# parameter is not specified, the default value is "en".Supported
|
146
|
+
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
147
|
+
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
148
|
+
# 'ja', 'pt', 'zh'
|
122
149
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
123
150
|
# will be added to the HTTP request.
|
124
151
|
#
|
125
|
-
# @return [
|
152
|
+
# @return [ImageAnalysis] operation results.
|
126
153
|
#
|
127
|
-
def
|
128
|
-
response =
|
154
|
+
def analyze_image(url, visual_features:nil, details:nil, language:nil, custom_headers:nil)
|
155
|
+
response = analyze_image_async(url, visual_features:visual_features, details:details, language:language, custom_headers:custom_headers).value!
|
129
156
|
response.body unless response.nil?
|
130
157
|
end
|
131
158
|
|
132
159
|
#
|
133
|
-
# This operation
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
160
|
+
# This operation extracts a rich set of visual features based on the image
|
161
|
+
# content.
|
162
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
163
|
+
# an image URL. Within your request, there is an optional parameter to allow
|
164
|
+
# you to choose which features to return. By default, image categories are
|
165
|
+
# returned in the response.
|
166
|
+
# A successful response will be returned in JSON. If the request failed, the
|
167
|
+
# response will contain an error code and a message to help understand what
|
168
|
+
# went wrong.
|
169
|
+
#
|
170
|
+
# @param url [String] Publicly reachable URL of an image.
|
171
|
+
# @param visual_features [Array<VisualFeatureTypes>] A string indicating what
|
172
|
+
# visual feature types to return. Multiple values should be comma-separated.
|
173
|
+
# Valid visual feature types include: Categories - categorizes image content
|
174
|
+
# according to a taxonomy defined in documentation. Tags - tags the image with
|
175
|
+
# a detailed list of words related to the image content. Description -
|
176
|
+
# describes the image content with a complete English sentence. Faces - detects
|
177
|
+
# if faces are present. If present, generate coordinates, gender and age.
|
178
|
+
# ImageType - detects if image is clipart or a line drawing. Color - determines
|
179
|
+
# the accent color, dominant color, and whether an image is black&white. Adult
|
180
|
+
# - detects if the image is pornographic in nature (depicts nudity or a sex
|
181
|
+
# act). Sexually suggestive content is also detected. Objects - detects
|
182
|
+
# various objects within an image, including the approximate location. The
|
183
|
+
# Objects argument is only available in English.
|
184
|
+
# @param details [Array<Details>] A string indicating which domain-specific
|
185
|
+
# details to return. Multiple values should be comma-separated. Valid visual
|
186
|
+
# feature types include: Celebrities - identifies celebrities if detected in
|
187
|
+
# the image, Landmarks - identifies notable landmarks in the image.
|
188
|
+
# @param language [Enum] The desired language for output generation. If this
|
189
|
+
# parameter is not specified, the default value is "en".Supported
|
190
|
+
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
191
|
+
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
192
|
+
# 'ja', 'pt', 'zh'
|
139
193
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
140
194
|
# will be added to the HTTP request.
|
141
195
|
#
|
142
196
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
143
197
|
#
|
144
|
-
def
|
145
|
-
|
198
|
+
def analyze_image_with_http_info(url, visual_features:nil, details:nil, language:nil, custom_headers:nil)
|
199
|
+
analyze_image_async(url, visual_features:visual_features, details:details, language:language, custom_headers:custom_headers).value!
|
146
200
|
end
|
147
201
|
|
148
202
|
#
|
149
|
-
# This operation
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
203
|
+
# This operation extracts a rich set of visual features based on the image
|
204
|
+
# content.
|
205
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
206
|
+
# an image URL. Within your request, there is an optional parameter to allow
|
207
|
+
# you to choose which features to return. By default, image categories are
|
208
|
+
# returned in the response.
|
209
|
+
# A successful response will be returned in JSON. If the request failed, the
|
210
|
+
# response will contain an error code and a message to help understand what
|
211
|
+
# went wrong.
|
212
|
+
#
|
213
|
+
# @param url [String] Publicly reachable URL of an image.
|
214
|
+
# @param visual_features [Array<VisualFeatureTypes>] A string indicating what
|
215
|
+
# visual feature types to return. Multiple values should be comma-separated.
|
216
|
+
# Valid visual feature types include: Categories - categorizes image content
|
217
|
+
# according to a taxonomy defined in documentation. Tags - tags the image with
|
218
|
+
# a detailed list of words related to the image content. Description -
|
219
|
+
# describes the image content with a complete English sentence. Faces - detects
|
220
|
+
# if faces are present. If present, generate coordinates, gender and age.
|
221
|
+
# ImageType - detects if image is clipart or a line drawing. Color - determines
|
222
|
+
# the accent color, dominant color, and whether an image is black&white. Adult
|
223
|
+
# - detects if the image is pornographic in nature (depicts nudity or a sex
|
224
|
+
# act). Sexually suggestive content is also detected. Objects - detects
|
225
|
+
# various objects within an image, including the approximate location. The
|
226
|
+
# Objects argument is only available in English.
|
227
|
+
# @param details [Array<Details>] A string indicating which domain-specific
|
228
|
+
# details to return. Multiple values should be comma-separated. Valid visual
|
229
|
+
# feature types include: Celebrities - identifies celebrities if detected in
|
230
|
+
# the image, Landmarks - identifies notable landmarks in the image.
|
231
|
+
# @param language [Enum] The desired language for output generation. If this
|
232
|
+
# parameter is not specified, the default value is "en".Supported
|
233
|
+
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
234
|
+
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
235
|
+
# 'ja', 'pt', 'zh'
|
155
236
|
# @param [Hash{String => String}] A hash of custom headers that will be added
|
156
237
|
# to the HTTP request.
|
157
238
|
#
|
158
239
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
159
240
|
#
|
160
|
-
def
|
241
|
+
def analyze_image_async(url, visual_features:nil, details:nil, language:nil, custom_headers:nil)
|
161
242
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
243
|
+
fail ArgumentError, 'url is nil' if url.nil?
|
162
244
|
|
245
|
+
image_url = ImageUrl.new
|
246
|
+
unless url.nil?
|
247
|
+
image_url.url = url
|
248
|
+
end
|
163
249
|
|
164
250
|
request_headers = {}
|
165
251
|
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
@@ -167,17 +253,25 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
167
253
|
# Set Headers
|
168
254
|
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
169
255
|
request_headers['accept-language'] = accept_language unless accept_language.nil?
|
170
|
-
|
256
|
+
|
257
|
+
# Serialize Request
|
258
|
+
request_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::ImageUrl.mapper()
|
259
|
+
request_content = self.serialize(request_mapper, image_url)
|
260
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
261
|
+
|
262
|
+
path_template = 'analyze'
|
171
263
|
|
172
264
|
request_url = @base_url || self.base_url
|
173
265
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
174
266
|
|
175
267
|
options = {
|
176
268
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
269
|
+
query_params: {'visualFeatures' => visual_features.nil? ? nil : visual_features.join(','),'details' => details.nil? ? nil : details.join(','),'language' => language},
|
270
|
+
body: request_content,
|
177
271
|
headers: request_headers.merge(custom_headers || {}),
|
178
272
|
base_url: request_url
|
179
273
|
}
|
180
|
-
promise = self.make_request_async(:
|
274
|
+
promise = self.make_request_async(:post, path_template, options)
|
181
275
|
|
182
276
|
promise = promise.then do |result|
|
183
277
|
http_response = result.response
|
@@ -193,7 +287,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
193
287
|
if status_code == 200
|
194
288
|
begin
|
195
289
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
196
|
-
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::
|
290
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::ImageAnalysis.mapper()
|
197
291
|
result.body = self.deserialize(result_mapper, parsed_response)
|
198
292
|
rescue Exception => e
|
199
293
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -207,28 +301,20 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
207
301
|
end
|
208
302
|
|
209
303
|
#
|
210
|
-
# This operation
|
211
|
-
#
|
212
|
-
#
|
213
|
-
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
218
|
-
#
|
219
|
-
#
|
220
|
-
#
|
221
|
-
#
|
222
|
-
#
|
223
|
-
#
|
224
|
-
# ImageType - detects if image is clipart or a line drawing. Color - determines
|
225
|
-
# the accent color, dominant color, and whether an image is black&white.Adult -
|
226
|
-
# detects if the image is pornographic in nature (depicts nudity or a sex act).
|
227
|
-
# Sexually suggestive content is also detected.
|
228
|
-
# @param details [Array<Details>] A string indicating which domain-specific
|
229
|
-
# details to return. Multiple values should be comma-separated. Valid visual
|
230
|
-
# feature types include:Celebrities - identifies celebrities if detected in the
|
231
|
-
# image.
|
304
|
+
# This operation generates a description of an image in human readable language
|
305
|
+
# with complete sentences. The description is based on a collection of content
|
306
|
+
# tags, which are also returned by the operation. More than one description can
|
307
|
+
# be generated for each image. Descriptions are ordered by their confidence
|
308
|
+
# score. All descriptions are in English.
|
309
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
310
|
+
# an image URL.
|
311
|
+
# A successful response will be returned in JSON. If the request failed, the
|
312
|
+
# response will contain an error code and a message to help understand what
|
313
|
+
# went wrong.
|
314
|
+
#
|
315
|
+
# @param url [String] Publicly reachable URL of an image.
|
316
|
+
# @param max_candidates [Integer] Maximum number of candidate descriptions to
|
317
|
+
# be returned. The default is 1.
|
232
318
|
# @param language [Enum] The desired language for output generation. If this
|
233
319
|
# parameter is not specified, the default value is "en".Supported
|
234
320
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -237,36 +323,28 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
237
323
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
238
324
|
# will be added to the HTTP request.
|
239
325
|
#
|
240
|
-
# @return [
|
326
|
+
# @return [ImageDescription] operation results.
|
241
327
|
#
|
242
|
-
def
|
243
|
-
response =
|
328
|
+
def describe_image(url, max_candidates:1, language:nil, custom_headers:nil)
|
329
|
+
response = describe_image_async(url, max_candidates:max_candidates, language:language, custom_headers:custom_headers).value!
|
244
330
|
response.body unless response.nil?
|
245
331
|
end
|
246
332
|
|
247
333
|
#
|
248
|
-
# This operation
|
249
|
-
#
|
250
|
-
#
|
251
|
-
#
|
252
|
-
#
|
253
|
-
#
|
254
|
-
#
|
255
|
-
#
|
256
|
-
#
|
257
|
-
#
|
258
|
-
#
|
259
|
-
#
|
260
|
-
#
|
261
|
-
#
|
262
|
-
# ImageType - detects if image is clipart or a line drawing. Color - determines
|
263
|
-
# the accent color, dominant color, and whether an image is black&white.Adult -
|
264
|
-
# detects if the image is pornographic in nature (depicts nudity or a sex act).
|
265
|
-
# Sexually suggestive content is also detected.
|
266
|
-
# @param details [Array<Details>] A string indicating which domain-specific
|
267
|
-
# details to return. Multiple values should be comma-separated. Valid visual
|
268
|
-
# feature types include:Celebrities - identifies celebrities if detected in the
|
269
|
-
# image.
|
334
|
+
# This operation generates a description of an image in human readable language
|
335
|
+
# with complete sentences. The description is based on a collection of content
|
336
|
+
# tags, which are also returned by the operation. More than one description can
|
337
|
+
# be generated for each image. Descriptions are ordered by their confidence
|
338
|
+
# score. All descriptions are in English.
|
339
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
340
|
+
# an image URL.
|
341
|
+
# A successful response will be returned in JSON. If the request failed, the
|
342
|
+
# response will contain an error code and a message to help understand what
|
343
|
+
# went wrong.
|
344
|
+
#
|
345
|
+
# @param url [String] Publicly reachable URL of an image.
|
346
|
+
# @param max_candidates [Integer] Maximum number of candidate descriptions to
|
347
|
+
# be returned. The default is 1.
|
270
348
|
# @param language [Enum] The desired language for output generation. If this
|
271
349
|
# parameter is not specified, the default value is "en".Supported
|
272
350
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -277,33 +355,25 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
277
355
|
#
|
278
356
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
279
357
|
#
|
280
|
-
def
|
281
|
-
|
358
|
+
def describe_image_with_http_info(url, max_candidates:1, language:nil, custom_headers:nil)
|
359
|
+
describe_image_async(url, max_candidates:max_candidates, language:language, custom_headers:custom_headers).value!
|
282
360
|
end
|
283
361
|
|
284
362
|
#
|
285
|
-
# This operation
|
286
|
-
#
|
287
|
-
#
|
288
|
-
#
|
289
|
-
#
|
290
|
-
#
|
291
|
-
#
|
292
|
-
#
|
293
|
-
#
|
294
|
-
#
|
295
|
-
#
|
296
|
-
#
|
297
|
-
#
|
298
|
-
#
|
299
|
-
# ImageType - detects if image is clipart or a line drawing. Color - determines
|
300
|
-
# the accent color, dominant color, and whether an image is black&white.Adult -
|
301
|
-
# detects if the image is pornographic in nature (depicts nudity or a sex act).
|
302
|
-
# Sexually suggestive content is also detected.
|
303
|
-
# @param details [Array<Details>] A string indicating which domain-specific
|
304
|
-
# details to return. Multiple values should be comma-separated. Valid visual
|
305
|
-
# feature types include:Celebrities - identifies celebrities if detected in the
|
306
|
-
# image.
|
363
|
+
# This operation generates a description of an image in human readable language
|
364
|
+
# with complete sentences. The description is based on a collection of content
|
365
|
+
# tags, which are also returned by the operation. More than one description can
|
366
|
+
# be generated for each image. Descriptions are ordered by their confidence
|
367
|
+
# score. All descriptions are in English.
|
368
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
369
|
+
# an image URL.
|
370
|
+
# A successful response will be returned in JSON. If the request failed, the
|
371
|
+
# response will contain an error code and a message to help understand what
|
372
|
+
# went wrong.
|
373
|
+
#
|
374
|
+
# @param url [String] Publicly reachable URL of an image.
|
375
|
+
# @param max_candidates [Integer] Maximum number of candidate descriptions to
|
376
|
+
# be returned. The default is 1.
|
307
377
|
# @param language [Enum] The desired language for output generation. If this
|
308
378
|
# parameter is not specified, the default value is "en".Supported
|
309
379
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -314,14 +384,231 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
314
384
|
#
|
315
385
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
316
386
|
#
|
317
|
-
def
|
387
|
+
def describe_image_async(url, max_candidates:1, language:nil, custom_headers:nil)
|
388
|
+
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
389
|
+
fail ArgumentError, 'url is nil' if url.nil?
|
390
|
+
|
391
|
+
image_url = ImageUrl.new
|
392
|
+
unless url.nil?
|
393
|
+
image_url.url = url
|
394
|
+
end
|
395
|
+
|
396
|
+
request_headers = {}
|
397
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
398
|
+
|
399
|
+
# Set Headers
|
400
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
401
|
+
request_headers['accept-language'] = accept_language unless accept_language.nil?
|
402
|
+
|
403
|
+
# Serialize Request
|
404
|
+
request_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::ImageUrl.mapper()
|
405
|
+
request_content = self.serialize(request_mapper, image_url)
|
406
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
407
|
+
|
408
|
+
path_template = 'describe'
|
409
|
+
|
410
|
+
request_url = @base_url || self.base_url
|
411
|
+
request_url = request_url.gsub('{Endpoint}', endpoint)
|
412
|
+
|
413
|
+
options = {
|
414
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
415
|
+
query_params: {'maxCandidates' => max_candidates,'language' => language},
|
416
|
+
body: request_content,
|
417
|
+
headers: request_headers.merge(custom_headers || {}),
|
418
|
+
base_url: request_url
|
419
|
+
}
|
420
|
+
promise = self.make_request_async(:post, path_template, options)
|
421
|
+
|
422
|
+
promise = promise.then do |result|
|
423
|
+
http_response = result.response
|
424
|
+
status_code = http_response.status
|
425
|
+
response_content = http_response.body
|
426
|
+
unless status_code == 200
|
427
|
+
error_model = JSON.load(response_content)
|
428
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
429
|
+
end
|
430
|
+
|
431
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
432
|
+
# Deserialize Response
|
433
|
+
if status_code == 200
|
434
|
+
begin
|
435
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
436
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::ImageDescription.mapper()
|
437
|
+
result.body = self.deserialize(result_mapper, parsed_response)
|
438
|
+
rescue Exception => e
|
439
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
result
|
444
|
+
end
|
445
|
+
|
446
|
+
promise.execute
|
447
|
+
end
|
448
|
+
|
449
|
+
#
|
450
|
+
# Performs object detection on the specified image.
|
451
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
452
|
+
# an image URL.
|
453
|
+
# A successful response will be returned in JSON. If the request failed, the
|
454
|
+
# response will contain an error code and a message to help understand what
|
455
|
+
# went wrong.
|
456
|
+
#
|
457
|
+
# @param url [String] Publicly reachable URL of an image.
|
458
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
459
|
+
# will be added to the HTTP request.
|
460
|
+
#
|
461
|
+
# @return [DetectResult] operation results.
|
462
|
+
#
|
463
|
+
def detect_objects(url, custom_headers:nil)
|
464
|
+
response = detect_objects_async(url, custom_headers:custom_headers).value!
|
465
|
+
response.body unless response.nil?
|
466
|
+
end
|
467
|
+
|
468
|
+
#
|
469
|
+
# Performs object detection on the specified image.
|
470
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
471
|
+
# an image URL.
|
472
|
+
# A successful response will be returned in JSON. If the request failed, the
|
473
|
+
# response will contain an error code and a message to help understand what
|
474
|
+
# went wrong.
|
475
|
+
#
|
476
|
+
# @param url [String] Publicly reachable URL of an image.
|
477
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
478
|
+
# will be added to the HTTP request.
|
479
|
+
#
|
480
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
481
|
+
#
|
482
|
+
def detect_objects_with_http_info(url, custom_headers:nil)
|
483
|
+
detect_objects_async(url, custom_headers:custom_headers).value!
|
484
|
+
end
|
485
|
+
|
486
|
+
#
|
487
|
+
# Performs object detection on the specified image.
|
488
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
489
|
+
# an image URL.
|
490
|
+
# A successful response will be returned in JSON. If the request failed, the
|
491
|
+
# response will contain an error code and a message to help understand what
|
492
|
+
# went wrong.
|
493
|
+
#
|
494
|
+
# @param url [String] Publicly reachable URL of an image.
|
495
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
496
|
+
# to the HTTP request.
|
497
|
+
#
|
498
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
499
|
+
#
|
500
|
+
def detect_objects_async(url, custom_headers:nil)
|
501
|
+
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
502
|
+
fail ArgumentError, 'url is nil' if url.nil?
|
503
|
+
|
504
|
+
image_url = ImageUrl.new
|
505
|
+
unless url.nil?
|
506
|
+
image_url.url = url
|
507
|
+
end
|
508
|
+
|
509
|
+
request_headers = {}
|
510
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
511
|
+
|
512
|
+
# Set Headers
|
513
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
514
|
+
request_headers['accept-language'] = accept_language unless accept_language.nil?
|
515
|
+
|
516
|
+
# Serialize Request
|
517
|
+
request_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::ImageUrl.mapper()
|
518
|
+
request_content = self.serialize(request_mapper, image_url)
|
519
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
520
|
+
|
521
|
+
path_template = 'detect'
|
522
|
+
|
523
|
+
request_url = @base_url || self.base_url
|
524
|
+
request_url = request_url.gsub('{Endpoint}', endpoint)
|
525
|
+
|
526
|
+
options = {
|
527
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
528
|
+
body: request_content,
|
529
|
+
headers: request_headers.merge(custom_headers || {}),
|
530
|
+
base_url: request_url
|
531
|
+
}
|
532
|
+
promise = self.make_request_async(:post, path_template, options)
|
533
|
+
|
534
|
+
promise = promise.then do |result|
|
535
|
+
http_response = result.response
|
536
|
+
status_code = http_response.status
|
537
|
+
response_content = http_response.body
|
538
|
+
unless status_code == 200
|
539
|
+
error_model = JSON.load(response_content)
|
540
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
541
|
+
end
|
542
|
+
|
543
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
544
|
+
# Deserialize Response
|
545
|
+
if status_code == 200
|
546
|
+
begin
|
547
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
548
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::DetectResult.mapper()
|
549
|
+
result.body = self.deserialize(result_mapper, parsed_response)
|
550
|
+
rescue Exception => e
|
551
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
552
|
+
end
|
553
|
+
end
|
554
|
+
|
555
|
+
result
|
556
|
+
end
|
557
|
+
|
558
|
+
promise.execute
|
559
|
+
end
|
560
|
+
|
561
|
+
#
|
562
|
+
# This operation returns the list of domain-specific models that are supported
|
563
|
+
# by the Computer Vision API. Currently, the API supports following
|
564
|
+
# domain-specific models: celebrity recognizer, landmark recognizer.
|
565
|
+
# A successful response will be returned in JSON. If the request failed, the
|
566
|
+
# response will contain an error code and a message to help understand what
|
567
|
+
# went wrong.
|
568
|
+
#
|
569
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
570
|
+
# will be added to the HTTP request.
|
571
|
+
#
|
572
|
+
# @return [ListModelsResult] operation results.
|
573
|
+
#
|
574
|
+
def list_models(custom_headers:nil)
|
575
|
+
response = list_models_async(custom_headers:custom_headers).value!
|
576
|
+
response.body unless response.nil?
|
577
|
+
end
|
578
|
+
|
579
|
+
#
|
580
|
+
# This operation returns the list of domain-specific models that are supported
|
581
|
+
# by the Computer Vision API. Currently, the API supports following
|
582
|
+
# domain-specific models: celebrity recognizer, landmark recognizer.
|
583
|
+
# A successful response will be returned in JSON. If the request failed, the
|
584
|
+
# response will contain an error code and a message to help understand what
|
585
|
+
# went wrong.
|
586
|
+
#
|
587
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
588
|
+
# will be added to the HTTP request.
|
589
|
+
#
|
590
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
591
|
+
#
|
592
|
+
def list_models_with_http_info(custom_headers:nil)
|
593
|
+
list_models_async(custom_headers:custom_headers).value!
|
594
|
+
end
|
595
|
+
|
596
|
+
#
|
597
|
+
# This operation returns the list of domain-specific models that are supported
|
598
|
+
# by the Computer Vision API. Currently, the API supports following
|
599
|
+
# domain-specific models: celebrity recognizer, landmark recognizer.
|
600
|
+
# A successful response will be returned in JSON. If the request failed, the
|
601
|
+
# response will contain an error code and a message to help understand what
|
602
|
+
# went wrong.
|
603
|
+
#
|
604
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
605
|
+
# to the HTTP request.
|
606
|
+
#
|
607
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
608
|
+
#
|
609
|
+
def list_models_async(custom_headers:nil)
|
318
610
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
319
|
-
fail ArgumentError, 'url is nil' if url.nil?
|
320
611
|
|
321
|
-
image_url = ImageUrl.new
|
322
|
-
unless url.nil?
|
323
|
-
image_url.url = url
|
324
|
-
end
|
325
612
|
|
326
613
|
request_headers = {}
|
327
614
|
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
@@ -329,25 +616,17 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
329
616
|
# Set Headers
|
330
617
|
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
331
618
|
request_headers['accept-language'] = accept_language unless accept_language.nil?
|
332
|
-
|
333
|
-
# Serialize Request
|
334
|
-
request_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::ImageUrl.mapper()
|
335
|
-
request_content = self.serialize(request_mapper, image_url)
|
336
|
-
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
337
|
-
|
338
|
-
path_template = 'analyze'
|
619
|
+
path_template = 'models'
|
339
620
|
|
340
621
|
request_url = @base_url || self.base_url
|
341
622
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
342
623
|
|
343
624
|
options = {
|
344
625
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
345
|
-
query_params: {'visualFeatures' => visual_features.nil? ? nil : visual_features.join(','),'details' => details.nil? ? nil : details.join(','),'language' => language},
|
346
|
-
body: request_content,
|
347
626
|
headers: request_headers.merge(custom_headers || {}),
|
348
627
|
base_url: request_url
|
349
628
|
}
|
350
|
-
promise = self.make_request_async(:
|
629
|
+
promise = self.make_request_async(:get, path_template, options)
|
351
630
|
|
352
631
|
promise = promise.then do |result|
|
353
632
|
http_response = result.response
|
@@ -363,7 +642,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
363
642
|
if status_code == 200
|
364
643
|
begin
|
365
644
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
366
|
-
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::
|
645
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::ListModelsResult.mapper()
|
367
646
|
result.body = self.deserialize(result_mapper, parsed_response)
|
368
647
|
rescue Exception => e
|
369
648
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -377,82 +656,89 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
377
656
|
end
|
378
657
|
|
379
658
|
#
|
380
|
-
# This operation
|
381
|
-
#
|
382
|
-
#
|
383
|
-
#
|
384
|
-
#
|
385
|
-
#
|
386
|
-
#
|
387
|
-
#
|
388
|
-
#
|
389
|
-
#
|
390
|
-
#
|
391
|
-
#
|
392
|
-
# @param url [String] Publicly reachable URL of an image
|
393
|
-
# @param
|
659
|
+
# This operation recognizes content within an image by applying a
|
660
|
+
# domain-specific model. The list of domain-specific models that are supported
|
661
|
+
# by the Computer Vision API can be retrieved using the /models GET request.
|
662
|
+
# Currently, the API provides following domain-specific models: celebrities,
|
663
|
+
# landmarks.
|
664
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
665
|
+
# an image URL.
|
666
|
+
# A successful response will be returned in JSON.
|
667
|
+
# If the request failed, the response will contain an error code and a message
|
668
|
+
# to help understand what went wrong.
|
669
|
+
#
|
670
|
+
# @param model [String] The domain-specific content to recognize.
|
671
|
+
# @param url [String] Publicly reachable URL of an image.
|
672
|
+
# @param language [Enum] The desired language for output generation. If this
|
673
|
+
# parameter is not specified, the default value is "en".Supported
|
674
|
+
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
675
|
+
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
676
|
+
# 'ja', 'pt', 'zh'
|
394
677
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
395
678
|
# will be added to the HTTP request.
|
396
679
|
#
|
397
|
-
# @return [
|
680
|
+
# @return [DomainModelResults] operation results.
|
398
681
|
#
|
399
|
-
def
|
400
|
-
response =
|
682
|
+
def analyze_image_by_domain(model, url, language:nil, custom_headers:nil)
|
683
|
+
response = analyze_image_by_domain_async(model, url, language:language, custom_headers:custom_headers).value!
|
401
684
|
response.body unless response.nil?
|
402
685
|
end
|
403
686
|
|
404
687
|
#
|
405
|
-
# This operation
|
406
|
-
#
|
407
|
-
#
|
408
|
-
#
|
409
|
-
#
|
410
|
-
#
|
411
|
-
#
|
412
|
-
#
|
413
|
-
#
|
414
|
-
#
|
415
|
-
#
|
416
|
-
#
|
417
|
-
# @param url [String] Publicly reachable URL of an image
|
418
|
-
# @param
|
688
|
+
# This operation recognizes content within an image by applying a
|
689
|
+
# domain-specific model. The list of domain-specific models that are supported
|
690
|
+
# by the Computer Vision API can be retrieved using the /models GET request.
|
691
|
+
# Currently, the API provides following domain-specific models: celebrities,
|
692
|
+
# landmarks.
|
693
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
694
|
+
# an image URL.
|
695
|
+
# A successful response will be returned in JSON.
|
696
|
+
# If the request failed, the response will contain an error code and a message
|
697
|
+
# to help understand what went wrong.
|
698
|
+
#
|
699
|
+
# @param model [String] The domain-specific content to recognize.
|
700
|
+
# @param url [String] Publicly reachable URL of an image.
|
701
|
+
# @param language [Enum] The desired language for output generation. If this
|
702
|
+
# parameter is not specified, the default value is "en".Supported
|
703
|
+
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
704
|
+
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
705
|
+
# 'ja', 'pt', 'zh'
|
419
706
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
420
707
|
# will be added to the HTTP request.
|
421
708
|
#
|
422
709
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
423
710
|
#
|
424
|
-
def
|
425
|
-
|
711
|
+
def analyze_image_by_domain_with_http_info(model, url, language:nil, custom_headers:nil)
|
712
|
+
analyze_image_by_domain_async(model, url, language:language, custom_headers:custom_headers).value!
|
426
713
|
end
|
427
714
|
|
428
715
|
#
|
429
|
-
# This operation
|
430
|
-
#
|
431
|
-
#
|
432
|
-
#
|
433
|
-
#
|
434
|
-
#
|
435
|
-
#
|
436
|
-
#
|
437
|
-
#
|
438
|
-
#
|
439
|
-
#
|
440
|
-
#
|
441
|
-
# @param url [String] Publicly reachable URL of an image
|
442
|
-
# @param
|
716
|
+
# This operation recognizes content within an image by applying a
|
717
|
+
# domain-specific model. The list of domain-specific models that are supported
|
718
|
+
# by the Computer Vision API can be retrieved using the /models GET request.
|
719
|
+
# Currently, the API provides following domain-specific models: celebrities,
|
720
|
+
# landmarks.
|
721
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
722
|
+
# an image URL.
|
723
|
+
# A successful response will be returned in JSON.
|
724
|
+
# If the request failed, the response will contain an error code and a message
|
725
|
+
# to help understand what went wrong.
|
726
|
+
#
|
727
|
+
# @param model [String] The domain-specific content to recognize.
|
728
|
+
# @param url [String] Publicly reachable URL of an image.
|
729
|
+
# @param language [Enum] The desired language for output generation. If this
|
730
|
+
# parameter is not specified, the default value is "en".Supported
|
731
|
+
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
732
|
+
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
733
|
+
# 'ja', 'pt', 'zh'
|
443
734
|
# @param [Hash{String => String}] A hash of custom headers that will be added
|
444
735
|
# to the HTTP request.
|
445
736
|
#
|
446
737
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
447
738
|
#
|
448
|
-
def
|
739
|
+
def analyze_image_by_domain_async(model, url, language:nil, custom_headers:nil)
|
449
740
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
450
|
-
fail ArgumentError, '
|
451
|
-
fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMaximum': '1023'" if !width.nil? && width > 1023
|
452
|
-
fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMinimum': '1'" if !width.nil? && width < 1
|
453
|
-
fail ArgumentError, 'height is nil' if height.nil?
|
454
|
-
fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMaximum': '1023'" if !height.nil? && height > 1023
|
455
|
-
fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMinimum': '1'" if !height.nil? && height < 1
|
741
|
+
fail ArgumentError, 'model is nil' if model.nil?
|
456
742
|
fail ArgumentError, 'url is nil' if url.nil?
|
457
743
|
|
458
744
|
image_url = ImageUrl.new
|
@@ -472,14 +758,15 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
472
758
|
request_content = self.serialize(request_mapper, image_url)
|
473
759
|
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
474
760
|
|
475
|
-
path_template = '
|
761
|
+
path_template = 'models/{model}/analyze'
|
476
762
|
|
477
763
|
request_url = @base_url || self.base_url
|
478
764
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
479
765
|
|
480
766
|
options = {
|
481
767
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
482
|
-
|
768
|
+
path_params: {'model' => model},
|
769
|
+
query_params: {'language' => language},
|
483
770
|
body: request_content,
|
484
771
|
headers: request_headers.merge(custom_headers || {}),
|
485
772
|
base_url: request_url
|
@@ -492,7 +779,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
492
779
|
response_content = http_response.body
|
493
780
|
unless status_code == 200
|
494
781
|
error_model = JSON.load(response_content)
|
495
|
-
fail
|
782
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
496
783
|
end
|
497
784
|
|
498
785
|
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
@@ -500,14 +787,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
500
787
|
if status_code == 200
|
501
788
|
begin
|
502
789
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
503
|
-
result_mapper =
|
504
|
-
client_side_validation: true,
|
505
|
-
required: false,
|
506
|
-
serialized_name: 'parsed_response',
|
507
|
-
type: {
|
508
|
-
name: 'Stream'
|
509
|
-
}
|
510
|
-
}
|
790
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::DomainModelResults.mapper()
|
511
791
|
result.body = self.deserialize(result_mapper, parsed_response)
|
512
792
|
rescue Exception => e
|
513
793
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -521,18 +801,19 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
521
801
|
end
|
522
802
|
|
523
803
|
#
|
524
|
-
# Optical Character Recognition (OCR) detects
|
525
|
-
#
|
526
|
-
# Upon success, the OCR results will be returned.
|
527
|
-
# together with an error message will be returned.
|
528
|
-
# InvalidImageUrl, InvalidImageFormat,
|
529
|
-
# NotSupportedLanguage, or
|
804
|
+
# Optical Character Recognition (OCR) detects text in an image and extracts the
|
805
|
+
# recognized characters into a machine-usable character stream.
|
806
|
+
# Upon success, the OCR results will be returned.
|
807
|
+
# Upon failure, the error code together with an error message will be returned.
|
808
|
+
# The error code can be one of InvalidImageUrl, InvalidImageFormat,
|
809
|
+
# InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or
|
810
|
+
# InternalServerError.
|
530
811
|
#
|
531
812
|
# @param detect_orientation [Boolean] Whether detect the text orientation in
|
532
813
|
# the image. With detectOrientation=true the OCR service tries to detect the
|
533
814
|
# image orientation and correct it before further processing (e.g. if it's
|
534
815
|
# upside-down).
|
535
|
-
# @param url [String] Publicly reachable URL of an image
|
816
|
+
# @param url [String] Publicly reachable URL of an image.
|
536
817
|
# @param language [OcrLanguages] The BCP-47 language code of the text to be
|
537
818
|
# detected in the image. The default value is 'unk'. Possible values include:
|
538
819
|
# 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el',
|
@@ -549,18 +830,19 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
549
830
|
end
|
550
831
|
|
551
832
|
#
|
552
|
-
# Optical Character Recognition (OCR) detects
|
553
|
-
#
|
554
|
-
# Upon success, the OCR results will be returned.
|
555
|
-
# together with an error message will be returned.
|
556
|
-
# InvalidImageUrl, InvalidImageFormat,
|
557
|
-
# NotSupportedLanguage, or
|
833
|
+
# Optical Character Recognition (OCR) detects text in an image and extracts the
|
834
|
+
# recognized characters into a machine-usable character stream.
|
835
|
+
# Upon success, the OCR results will be returned.
|
836
|
+
# Upon failure, the error code together with an error message will be returned.
|
837
|
+
# The error code can be one of InvalidImageUrl, InvalidImageFormat,
|
838
|
+
# InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or
|
839
|
+
# InternalServerError.
|
558
840
|
#
|
559
841
|
# @param detect_orientation [Boolean] Whether detect the text orientation in
|
560
842
|
# the image. With detectOrientation=true the OCR service tries to detect the
|
561
843
|
# image orientation and correct it before further processing (e.g. if it's
|
562
844
|
# upside-down).
|
563
|
-
# @param url [String] Publicly reachable URL of an image
|
845
|
+
# @param url [String] Publicly reachable URL of an image.
|
564
846
|
# @param language [OcrLanguages] The BCP-47 language code of the text to be
|
565
847
|
# detected in the image. The default value is 'unk'. Possible values include:
|
566
848
|
# 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el',
|
@@ -576,18 +858,19 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
576
858
|
end
|
577
859
|
|
578
860
|
#
|
579
|
-
# Optical Character Recognition (OCR) detects
|
580
|
-
#
|
581
|
-
# Upon success, the OCR results will be returned.
|
582
|
-
# together with an error message will be returned.
|
583
|
-
# InvalidImageUrl, InvalidImageFormat,
|
584
|
-
# NotSupportedLanguage, or
|
861
|
+
# Optical Character Recognition (OCR) detects text in an image and extracts the
|
862
|
+
# recognized characters into a machine-usable character stream.
|
863
|
+
# Upon success, the OCR results will be returned.
|
864
|
+
# Upon failure, the error code together with an error message will be returned.
|
865
|
+
# The error code can be one of InvalidImageUrl, InvalidImageFormat,
|
866
|
+
# InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or
|
867
|
+
# InternalServerError.
|
585
868
|
#
|
586
869
|
# @param detect_orientation [Boolean] Whether detect the text orientation in
|
587
870
|
# the image. With detectOrientation=true the OCR service tries to detect the
|
588
871
|
# image orientation and correct it before further processing (e.g. if it's
|
589
872
|
# upside-down).
|
590
|
-
# @param url [String] Publicly reachable URL of an image
|
873
|
+
# @param url [String] Publicly reachable URL of an image.
|
591
874
|
# @param language [OcrLanguages] The BCP-47 language code of the text to be
|
592
875
|
# detected in the image. The default value is 'unk'. Possible values include:
|
593
876
|
# 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el',
|
@@ -662,18 +945,20 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
662
945
|
end
|
663
946
|
|
664
947
|
#
|
665
|
-
# This operation generates a
|
666
|
-
#
|
667
|
-
#
|
668
|
-
#
|
669
|
-
#
|
670
|
-
#
|
671
|
-
#
|
672
|
-
#
|
673
|
-
#
|
674
|
-
#
|
675
|
-
#
|
676
|
-
#
|
948
|
+
# This operation generates a list of words, or tags, that are relevant to the
|
949
|
+
# content of the supplied image. The Computer Vision API can return tags based
|
950
|
+
# on objects, living beings, scenery or actions found in images. Unlike
|
951
|
+
# categories, tags are not organized according to a hierarchical classification
|
952
|
+
# system, but correspond to image content. Tags may contain hints to avoid
|
953
|
+
# ambiguity or provide context, for example the tag "cello" may be accompanied
|
954
|
+
# by the hint "musical instrument". All tags are in English.
|
955
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
956
|
+
# an image URL.
|
957
|
+
# A successful response will be returned in JSON. If the request failed, the
|
958
|
+
# response will contain an error code and a message to help understand what
|
959
|
+
# went wrong.
|
960
|
+
#
|
961
|
+
# @param url [String] Publicly reachable URL of an image.
|
677
962
|
# @param language [Enum] The desired language for output generation. If this
|
678
963
|
# parameter is not specified, the default value is "en".Supported
|
679
964
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -682,26 +967,28 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
682
967
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
683
968
|
# will be added to the HTTP request.
|
684
969
|
#
|
685
|
-
# @return [
|
970
|
+
# @return [TagResult] operation results.
|
686
971
|
#
|
687
|
-
def
|
688
|
-
response =
|
972
|
+
def tag_image(url, language:nil, custom_headers:nil)
|
973
|
+
response = tag_image_async(url, language:language, custom_headers:custom_headers).value!
|
689
974
|
response.body unless response.nil?
|
690
975
|
end
|
691
976
|
|
692
977
|
#
|
693
|
-
# This operation generates a
|
694
|
-
#
|
695
|
-
#
|
696
|
-
#
|
697
|
-
#
|
698
|
-
#
|
699
|
-
#
|
700
|
-
#
|
701
|
-
#
|
702
|
-
#
|
703
|
-
#
|
704
|
-
#
|
978
|
+
# This operation generates a list of words, or tags, that are relevant to the
|
979
|
+
# content of the supplied image. The Computer Vision API can return tags based
|
980
|
+
# on objects, living beings, scenery or actions found in images. Unlike
|
981
|
+
# categories, tags are not organized according to a hierarchical classification
|
982
|
+
# system, but correspond to image content. Tags may contain hints to avoid
|
983
|
+
# ambiguity or provide context, for example the tag "cello" may be accompanied
|
984
|
+
# by the hint "musical instrument". All tags are in English.
|
985
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
986
|
+
# an image URL.
|
987
|
+
# A successful response will be returned in JSON. If the request failed, the
|
988
|
+
# response will contain an error code and a message to help understand what
|
989
|
+
# went wrong.
|
990
|
+
#
|
991
|
+
# @param url [String] Publicly reachable URL of an image.
|
705
992
|
# @param language [Enum] The desired language for output generation. If this
|
706
993
|
# parameter is not specified, the default value is "en".Supported
|
707
994
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -712,23 +999,25 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
712
999
|
#
|
713
1000
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
714
1001
|
#
|
715
|
-
def
|
716
|
-
|
1002
|
+
def tag_image_with_http_info(url, language:nil, custom_headers:nil)
|
1003
|
+
tag_image_async(url, language:language, custom_headers:custom_headers).value!
|
717
1004
|
end
|
718
1005
|
|
719
1006
|
#
|
720
|
-
# This operation generates a
|
721
|
-
#
|
722
|
-
#
|
723
|
-
#
|
724
|
-
#
|
725
|
-
#
|
726
|
-
#
|
727
|
-
#
|
728
|
-
#
|
729
|
-
#
|
730
|
-
#
|
731
|
-
#
|
1007
|
+
# This operation generates a list of words, or tags, that are relevant to the
|
1008
|
+
# content of the supplied image. The Computer Vision API can return tags based
|
1009
|
+
# on objects, living beings, scenery or actions found in images. Unlike
|
1010
|
+
# categories, tags are not organized according to a hierarchical classification
|
1011
|
+
# system, but correspond to image content. Tags may contain hints to avoid
|
1012
|
+
# ambiguity or provide context, for example the tag "cello" may be accompanied
|
1013
|
+
# by the hint "musical instrument". All tags are in English.
|
1014
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
1015
|
+
# an image URL.
|
1016
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1017
|
+
# response will contain an error code and a message to help understand what
|
1018
|
+
# went wrong.
|
1019
|
+
#
|
1020
|
+
# @param url [String] Publicly reachable URL of an image.
|
732
1021
|
# @param language [Enum] The desired language for output generation. If this
|
733
1022
|
# parameter is not specified, the default value is "en".Supported
|
734
1023
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -739,7 +1028,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
739
1028
|
#
|
740
1029
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
741
1030
|
#
|
742
|
-
def
|
1031
|
+
def tag_image_async(url, language:nil, custom_headers:nil)
|
743
1032
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
744
1033
|
fail ArgumentError, 'url is nil' if url.nil?
|
745
1034
|
|
@@ -760,14 +1049,14 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
760
1049
|
request_content = self.serialize(request_mapper, image_url)
|
761
1050
|
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
762
1051
|
|
763
|
-
path_template = '
|
1052
|
+
path_template = 'tag'
|
764
1053
|
|
765
1054
|
request_url = @base_url || self.base_url
|
766
1055
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
767
1056
|
|
768
1057
|
options = {
|
769
1058
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
770
|
-
query_params: {'
|
1059
|
+
query_params: {'language' => language},
|
771
1060
|
body: request_content,
|
772
1061
|
headers: request_headers.merge(custom_headers || {}),
|
773
1062
|
base_url: request_url
|
@@ -788,7 +1077,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
788
1077
|
if status_code == 200
|
789
1078
|
begin
|
790
1079
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
791
|
-
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::
|
1080
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::TagResult.mapper()
|
792
1081
|
result.body = self.deserialize(result_mapper, parsed_response)
|
793
1082
|
rescue Exception => e
|
794
1083
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -802,76 +1091,97 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
802
1091
|
end
|
803
1092
|
|
804
1093
|
#
|
805
|
-
# This operation generates a
|
806
|
-
#
|
807
|
-
#
|
808
|
-
#
|
809
|
-
#
|
810
|
-
#
|
811
|
-
#
|
812
|
-
#
|
813
|
-
#
|
814
|
-
#
|
815
|
-
#
|
816
|
-
#
|
817
|
-
#
|
818
|
-
#
|
1094
|
+
# This operation generates a thumbnail image with the user-specified width and
|
1095
|
+
# height. By default, the service analyzes the image, identifies the region of
|
1096
|
+
# interest (ROI), and generates smart cropping coordinates based on the ROI.
|
1097
|
+
# Smart cropping helps when you specify an aspect ratio that differs from that
|
1098
|
+
# of the input image.
|
1099
|
+
# A successful response contains the thumbnail image binary. If the request
|
1100
|
+
# failed, the response contains an error code and a message to help determine
|
1101
|
+
# what went wrong.
|
1102
|
+
# Upon failure, the error code and an error message are returned. The error
|
1103
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
1104
|
+
# InvalidThumbnailSize, NotSupportedImage, FailedToProcess, Timeout, or
|
1105
|
+
# InternalServerError.
|
1106
|
+
#
|
1107
|
+
# @param width [Integer] Width of the thumbnail, in pixels. It must be between
|
1108
|
+
# 1 and 1024. Recommended minimum of 50.
|
1109
|
+
# @param height [Integer] Height of the thumbnail, in pixels. It must be
|
1110
|
+
# between 1 and 1024. Recommended minimum of 50.
|
1111
|
+
# @param url [String] Publicly reachable URL of an image.
|
1112
|
+
# @param smart_cropping [Boolean] Boolean flag for enabling smart cropping.
|
819
1113
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
820
1114
|
# will be added to the HTTP request.
|
821
1115
|
#
|
822
|
-
# @return [
|
1116
|
+
# @return [NOT_IMPLEMENTED] operation results.
|
823
1117
|
#
|
824
|
-
def
|
825
|
-
response =
|
1118
|
+
def generate_thumbnail(width, height, url, smart_cropping:false, custom_headers:nil)
|
1119
|
+
response = generate_thumbnail_async(width, height, url, smart_cropping:smart_cropping, custom_headers:custom_headers).value!
|
826
1120
|
response.body unless response.nil?
|
827
1121
|
end
|
828
1122
|
|
829
1123
|
#
|
830
|
-
# This operation generates a
|
831
|
-
#
|
832
|
-
#
|
833
|
-
#
|
834
|
-
#
|
835
|
-
#
|
836
|
-
#
|
837
|
-
#
|
838
|
-
#
|
839
|
-
#
|
840
|
-
#
|
841
|
-
#
|
842
|
-
#
|
843
|
-
#
|
1124
|
+
# This operation generates a thumbnail image with the user-specified width and
|
1125
|
+
# height. By default, the service analyzes the image, identifies the region of
|
1126
|
+
# interest (ROI), and generates smart cropping coordinates based on the ROI.
|
1127
|
+
# Smart cropping helps when you specify an aspect ratio that differs from that
|
1128
|
+
# of the input image.
|
1129
|
+
# A successful response contains the thumbnail image binary. If the request
|
1130
|
+
# failed, the response contains an error code and a message to help determine
|
1131
|
+
# what went wrong.
|
1132
|
+
# Upon failure, the error code and an error message are returned. The error
|
1133
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
1134
|
+
# InvalidThumbnailSize, NotSupportedImage, FailedToProcess, Timeout, or
|
1135
|
+
# InternalServerError.
|
1136
|
+
#
|
1137
|
+
# @param width [Integer] Width of the thumbnail, in pixels. It must be between
|
1138
|
+
# 1 and 1024. Recommended minimum of 50.
|
1139
|
+
# @param height [Integer] Height of the thumbnail, in pixels. It must be
|
1140
|
+
# between 1 and 1024. Recommended minimum of 50.
|
1141
|
+
# @param url [String] Publicly reachable URL of an image.
|
1142
|
+
# @param smart_cropping [Boolean] Boolean flag for enabling smart cropping.
|
844
1143
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
845
1144
|
# will be added to the HTTP request.
|
846
1145
|
#
|
847
1146
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
848
1147
|
#
|
849
|
-
def
|
850
|
-
|
1148
|
+
def generate_thumbnail_with_http_info(width, height, url, smart_cropping:false, custom_headers:nil)
|
1149
|
+
generate_thumbnail_async(width, height, url, smart_cropping:smart_cropping, custom_headers:custom_headers).value!
|
851
1150
|
end
|
852
1151
|
|
853
1152
|
#
|
854
|
-
# This operation generates a
|
855
|
-
#
|
856
|
-
#
|
857
|
-
#
|
858
|
-
#
|
859
|
-
#
|
860
|
-
#
|
861
|
-
#
|
862
|
-
#
|
863
|
-
#
|
864
|
-
#
|
865
|
-
#
|
866
|
-
#
|
867
|
-
#
|
1153
|
+
# This operation generates a thumbnail image with the user-specified width and
|
1154
|
+
# height. By default, the service analyzes the image, identifies the region of
|
1155
|
+
# interest (ROI), and generates smart cropping coordinates based on the ROI.
|
1156
|
+
# Smart cropping helps when you specify an aspect ratio that differs from that
|
1157
|
+
# of the input image.
|
1158
|
+
# A successful response contains the thumbnail image binary. If the request
|
1159
|
+
# failed, the response contains an error code and a message to help determine
|
1160
|
+
# what went wrong.
|
1161
|
+
# Upon failure, the error code and an error message are returned. The error
|
1162
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
1163
|
+
# InvalidThumbnailSize, NotSupportedImage, FailedToProcess, Timeout, or
|
1164
|
+
# InternalServerError.
|
1165
|
+
#
|
1166
|
+
# @param width [Integer] Width of the thumbnail, in pixels. It must be between
|
1167
|
+
# 1 and 1024. Recommended minimum of 50.
|
1168
|
+
# @param height [Integer] Height of the thumbnail, in pixels. It must be
|
1169
|
+
# between 1 and 1024. Recommended minimum of 50.
|
1170
|
+
# @param url [String] Publicly reachable URL of an image.
|
1171
|
+
# @param smart_cropping [Boolean] Boolean flag for enabling smart cropping.
|
868
1172
|
# @param [Hash{String => String}] A hash of custom headers that will be added
|
869
1173
|
# to the HTTP request.
|
870
1174
|
#
|
871
1175
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
872
1176
|
#
|
873
|
-
def
|
1177
|
+
def generate_thumbnail_async(width, height, url, smart_cropping:false, custom_headers:nil)
|
874
1178
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
1179
|
+
fail ArgumentError, 'width is nil' if width.nil?
|
1180
|
+
fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMaximum': '1024'" if !width.nil? && width > 1024
|
1181
|
+
fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMinimum': '1'" if !width.nil? && width < 1
|
1182
|
+
fail ArgumentError, 'height is nil' if height.nil?
|
1183
|
+
fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMaximum': '1024'" if !height.nil? && height > 1024
|
1184
|
+
fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMinimum': '1'" if !height.nil? && height < 1
|
875
1185
|
fail ArgumentError, 'url is nil' if url.nil?
|
876
1186
|
|
877
1187
|
image_url = ImageUrl.new
|
@@ -891,14 +1201,14 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
891
1201
|
request_content = self.serialize(request_mapper, image_url)
|
892
1202
|
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
893
1203
|
|
894
|
-
path_template = '
|
1204
|
+
path_template = 'generateThumbnail'
|
895
1205
|
|
896
1206
|
request_url = @base_url || self.base_url
|
897
1207
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
898
1208
|
|
899
1209
|
options = {
|
900
1210
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
901
|
-
query_params: {'
|
1211
|
+
query_params: {'width' => width,'height' => height,'smartCropping' => smart_cropping},
|
902
1212
|
body: request_content,
|
903
1213
|
headers: request_headers.merge(custom_headers || {}),
|
904
1214
|
base_url: request_url
|
@@ -911,7 +1221,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
911
1221
|
response_content = http_response.body
|
912
1222
|
unless status_code == 200
|
913
1223
|
error_model = JSON.load(response_content)
|
914
|
-
fail
|
1224
|
+
fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
|
915
1225
|
end
|
916
1226
|
|
917
1227
|
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
@@ -919,7 +1229,14 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
919
1229
|
if status_code == 200
|
920
1230
|
begin
|
921
1231
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
922
|
-
result_mapper =
|
1232
|
+
result_mapper = {
|
1233
|
+
client_side_validation: true,
|
1234
|
+
required: false,
|
1235
|
+
serialized_name: 'parsed_response',
|
1236
|
+
type: {
|
1237
|
+
name: 'Stream'
|
1238
|
+
}
|
1239
|
+
}
|
923
1240
|
result.body = self.deserialize(result_mapper, parsed_response)
|
924
1241
|
rescue Exception => e
|
925
1242
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -933,83 +1250,64 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
933
1250
|
end
|
934
1251
|
|
935
1252
|
#
|
936
|
-
# This operation
|
937
|
-
#
|
938
|
-
#
|
939
|
-
#
|
940
|
-
#
|
941
|
-
#
|
942
|
-
#
|
943
|
-
#
|
944
|
-
#
|
945
|
-
# @param
|
946
|
-
# @param url [String] Publicly reachable URL of an image
|
947
|
-
# @param language [Enum] The desired language for output generation. If this
|
948
|
-
# parameter is not specified, the default value is "en".Supported
|
949
|
-
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
950
|
-
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
951
|
-
# 'ja', 'pt', 'zh'
|
1253
|
+
# This operation returns a bounding box around the most important area of the
|
1254
|
+
# image.
|
1255
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1256
|
+
# response contains an error code and a message to help determine what went
|
1257
|
+
# wrong.
|
1258
|
+
# Upon failure, the error code and an error message are returned. The error
|
1259
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
1260
|
+
# NotSupportedImage, FailedToProcess, Timeout, or InternalServerError.
|
1261
|
+
#
|
1262
|
+
# @param url [String] Publicly reachable URL of an image.
|
952
1263
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
953
1264
|
# will be added to the HTTP request.
|
954
1265
|
#
|
955
|
-
# @return [
|
1266
|
+
# @return [AreaOfInterestResult] operation results.
|
956
1267
|
#
|
957
|
-
def
|
958
|
-
response =
|
1268
|
+
def get_area_of_interest(url, custom_headers:nil)
|
1269
|
+
response = get_area_of_interest_async(url, custom_headers:custom_headers).value!
|
959
1270
|
response.body unless response.nil?
|
960
1271
|
end
|
961
1272
|
|
962
|
-
#
|
963
|
-
# This operation
|
964
|
-
#
|
965
|
-
#
|
966
|
-
#
|
967
|
-
#
|
968
|
-
#
|
969
|
-
#
|
970
|
-
#
|
971
|
-
#
|
972
|
-
# @param
|
973
|
-
# @param url [String] Publicly reachable URL of an image
|
974
|
-
# @param language [Enum] The desired language for output generation. If this
|
975
|
-
# parameter is not specified, the default value is "en".Supported
|
976
|
-
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
977
|
-
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
978
|
-
# 'ja', 'pt', 'zh'
|
1273
|
+
#
|
1274
|
+
# This operation returns a bounding box around the most important area of the
|
1275
|
+
# image.
|
1276
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1277
|
+
# response contains an error code and a message to help determine what went
|
1278
|
+
# wrong.
|
1279
|
+
# Upon failure, the error code and an error message are returned. The error
|
1280
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
1281
|
+
# NotSupportedImage, FailedToProcess, Timeout, or InternalServerError.
|
1282
|
+
#
|
1283
|
+
# @param url [String] Publicly reachable URL of an image.
|
979
1284
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
980
1285
|
# will be added to the HTTP request.
|
981
1286
|
#
|
982
1287
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
983
1288
|
#
|
984
|
-
def
|
985
|
-
|
1289
|
+
def get_area_of_interest_with_http_info(url, custom_headers:nil)
|
1290
|
+
get_area_of_interest_async(url, custom_headers:custom_headers).value!
|
986
1291
|
end
|
987
1292
|
|
988
1293
|
#
|
989
|
-
# This operation
|
990
|
-
#
|
991
|
-
#
|
992
|
-
#
|
993
|
-
#
|
994
|
-
#
|
995
|
-
#
|
996
|
-
#
|
997
|
-
#
|
998
|
-
# @param
|
999
|
-
# @param url [String] Publicly reachable URL of an image
|
1000
|
-
# @param language [Enum] The desired language for output generation. If this
|
1001
|
-
# parameter is not specified, the default value is "en".Supported
|
1002
|
-
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
1003
|
-
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
1004
|
-
# 'ja', 'pt', 'zh'
|
1294
|
+
# This operation returns a bounding box around the most important area of the
|
1295
|
+
# image.
|
1296
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1297
|
+
# response contains an error code and a message to help determine what went
|
1298
|
+
# wrong.
|
1299
|
+
# Upon failure, the error code and an error message are returned. The error
|
1300
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
1301
|
+
# NotSupportedImage, FailedToProcess, Timeout, or InternalServerError.
|
1302
|
+
#
|
1303
|
+
# @param url [String] Publicly reachable URL of an image.
|
1005
1304
|
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1006
1305
|
# to the HTTP request.
|
1007
1306
|
#
|
1008
1307
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1009
1308
|
#
|
1010
|
-
def
|
1309
|
+
def get_area_of_interest_async(url, custom_headers:nil)
|
1011
1310
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
1012
|
-
fail ArgumentError, 'model is nil' if model.nil?
|
1013
1311
|
fail ArgumentError, 'url is nil' if url.nil?
|
1014
1312
|
|
1015
1313
|
image_url = ImageUrl.new
|
@@ -1029,15 +1327,13 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1029
1327
|
request_content = self.serialize(request_mapper, image_url)
|
1030
1328
|
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
1031
1329
|
|
1032
|
-
path_template = '
|
1330
|
+
path_template = 'areaOfInterest'
|
1033
1331
|
|
1034
1332
|
request_url = @base_url || self.base_url
|
1035
1333
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
1036
1334
|
|
1037
1335
|
options = {
|
1038
1336
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1039
|
-
path_params: {'model' => model},
|
1040
|
-
query_params: {'language' => language},
|
1041
1337
|
body: request_content,
|
1042
1338
|
headers: request_headers.merge(custom_headers || {}),
|
1043
1339
|
base_url: request_url
|
@@ -1058,7 +1354,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1058
1354
|
if status_code == 200
|
1059
1355
|
begin
|
1060
1356
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
1061
|
-
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::
|
1357
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::AreaOfInterestResult.mapper()
|
1062
1358
|
result.body = self.deserialize(result_mapper, parsed_response)
|
1063
1359
|
rescue Exception => e
|
1064
1360
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -1079,7 +1375,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1079
1375
|
#
|
1080
1376
|
# @param mode [TextRecognitionMode] Type of text to recognize. Possible values
|
1081
1377
|
# include: 'Handwritten', 'Printed'
|
1082
|
-
# @param url [String] Publicly reachable URL of an image
|
1378
|
+
# @param url [String] Publicly reachable URL of an image.
|
1083
1379
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1084
1380
|
# will be added to the HTTP request.
|
1085
1381
|
#
|
@@ -1097,7 +1393,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1097
1393
|
#
|
1098
1394
|
# @param mode [TextRecognitionMode] Type of text to recognize. Possible values
|
1099
1395
|
# include: 'Handwritten', 'Printed'
|
1100
|
-
# @param url [String] Publicly reachable URL of an image
|
1396
|
+
# @param url [String] Publicly reachable URL of an image.
|
1101
1397
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1102
1398
|
# will be added to the HTTP request.
|
1103
1399
|
#
|
@@ -1115,7 +1411,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1115
1411
|
#
|
1116
1412
|
# @param mode [TextRecognitionMode] Type of text to recognize. Possible values
|
1117
1413
|
# include: 'Handwritten', 'Printed'
|
1118
|
-
# @param url [String] Publicly reachable URL of an image
|
1414
|
+
# @param url [String] Publicly reachable URL of an image.
|
1119
1415
|
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1120
1416
|
# to the HTTP request.
|
1121
1417
|
#
|
@@ -1273,23 +1569,32 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1273
1569
|
#
|
1274
1570
|
# This operation extracts a rich set of visual features based on the image
|
1275
1571
|
# content.
|
1572
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
1573
|
+
# an image URL. Within your request, there is an optional parameter to allow
|
1574
|
+
# you to choose which features to return. By default, image categories are
|
1575
|
+
# returned in the response.
|
1576
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1577
|
+
# response will contain an error code and a message to help understand what
|
1578
|
+
# went wrong.
|
1276
1579
|
#
|
1277
1580
|
# @param image An image stream.
|
1278
1581
|
# @param visual_features [Array<VisualFeatureTypes>] A string indicating what
|
1279
1582
|
# visual feature types to return. Multiple values should be comma-separated.
|
1280
|
-
# Valid visual feature types include:Categories - categorizes image content
|
1583
|
+
# Valid visual feature types include: Categories - categorizes image content
|
1281
1584
|
# according to a taxonomy defined in documentation. Tags - tags the image with
|
1282
1585
|
# a detailed list of words related to the image content. Description -
|
1283
1586
|
# describes the image content with a complete English sentence. Faces - detects
|
1284
1587
|
# if faces are present. If present, generate coordinates, gender and age.
|
1285
1588
|
# ImageType - detects if image is clipart or a line drawing. Color - determines
|
1286
|
-
# the accent color, dominant color, and whether an image is black&white.Adult
|
1287
|
-
# detects if the image is pornographic in nature (depicts nudity or a sex
|
1288
|
-
# Sexually suggestive content is also detected.
|
1289
|
-
#
|
1290
|
-
#
|
1291
|
-
#
|
1292
|
-
#
|
1589
|
+
# the accent color, dominant color, and whether an image is black&white. Adult
|
1590
|
+
# - detects if the image is pornographic in nature (depicts nudity or a sex
|
1591
|
+
# act). Sexually suggestive content is also detected. Objects - detects
|
1592
|
+
# various objects within an image, including the approximate location. The
|
1593
|
+
# Objects argument is only available in English.
|
1594
|
+
# @param details [Array<Details>] A string indicating which domain-specific
|
1595
|
+
# details to return. Multiple values should be comma-separated. Valid visual
|
1596
|
+
# feature types include: Celebrities - identifies celebrities if detected in
|
1597
|
+
# the image, Landmarks - identifies notable landmarks in the image.
|
1293
1598
|
# @param language [Enum] The desired language for output generation. If this
|
1294
1599
|
# parameter is not specified, the default value is "en".Supported
|
1295
1600
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -1308,23 +1613,32 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1308
1613
|
#
|
1309
1614
|
# This operation extracts a rich set of visual features based on the image
|
1310
1615
|
# content.
|
1616
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
1617
|
+
# an image URL. Within your request, there is an optional parameter to allow
|
1618
|
+
# you to choose which features to return. By default, image categories are
|
1619
|
+
# returned in the response.
|
1620
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1621
|
+
# response will contain an error code and a message to help understand what
|
1622
|
+
# went wrong.
|
1311
1623
|
#
|
1312
1624
|
# @param image An image stream.
|
1313
1625
|
# @param visual_features [Array<VisualFeatureTypes>] A string indicating what
|
1314
1626
|
# visual feature types to return. Multiple values should be comma-separated.
|
1315
|
-
# Valid visual feature types include:Categories - categorizes image content
|
1627
|
+
# Valid visual feature types include: Categories - categorizes image content
|
1316
1628
|
# according to a taxonomy defined in documentation. Tags - tags the image with
|
1317
1629
|
# a detailed list of words related to the image content. Description -
|
1318
1630
|
# describes the image content with a complete English sentence. Faces - detects
|
1319
1631
|
# if faces are present. If present, generate coordinates, gender and age.
|
1320
1632
|
# ImageType - detects if image is clipart or a line drawing. Color - determines
|
1321
|
-
# the accent color, dominant color, and whether an image is black&white.Adult
|
1322
|
-
# detects if the image is pornographic in nature (depicts nudity or a sex
|
1323
|
-
# Sexually suggestive content is also detected.
|
1324
|
-
#
|
1325
|
-
#
|
1326
|
-
#
|
1327
|
-
#
|
1633
|
+
# the accent color, dominant color, and whether an image is black&white. Adult
|
1634
|
+
# - detects if the image is pornographic in nature (depicts nudity or a sex
|
1635
|
+
# act). Sexually suggestive content is also detected. Objects - detects
|
1636
|
+
# various objects within an image, including the approximate location. The
|
1637
|
+
# Objects argument is only available in English.
|
1638
|
+
# @param details [Array<Details>] A string indicating which domain-specific
|
1639
|
+
# details to return. Multiple values should be comma-separated. Valid visual
|
1640
|
+
# feature types include: Celebrities - identifies celebrities if detected in
|
1641
|
+
# the image, Landmarks - identifies notable landmarks in the image.
|
1328
1642
|
# @param language [Enum] The desired language for output generation. If this
|
1329
1643
|
# parameter is not specified, the default value is "en".Supported
|
1330
1644
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -1342,23 +1656,32 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1342
1656
|
#
|
1343
1657
|
# This operation extracts a rich set of visual features based on the image
|
1344
1658
|
# content.
|
1659
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
1660
|
+
# an image URL. Within your request, there is an optional parameter to allow
|
1661
|
+
# you to choose which features to return. By default, image categories are
|
1662
|
+
# returned in the response.
|
1663
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1664
|
+
# response will contain an error code and a message to help understand what
|
1665
|
+
# went wrong.
|
1345
1666
|
#
|
1346
1667
|
# @param image An image stream.
|
1347
1668
|
# @param visual_features [Array<VisualFeatureTypes>] A string indicating what
|
1348
1669
|
# visual feature types to return. Multiple values should be comma-separated.
|
1349
|
-
# Valid visual feature types include:Categories - categorizes image content
|
1670
|
+
# Valid visual feature types include: Categories - categorizes image content
|
1350
1671
|
# according to a taxonomy defined in documentation. Tags - tags the image with
|
1351
1672
|
# a detailed list of words related to the image content. Description -
|
1352
1673
|
# describes the image content with a complete English sentence. Faces - detects
|
1353
1674
|
# if faces are present. If present, generate coordinates, gender and age.
|
1354
1675
|
# ImageType - detects if image is clipart or a line drawing. Color - determines
|
1355
|
-
# the accent color, dominant color, and whether an image is black&white.Adult
|
1356
|
-
# detects if the image is pornographic in nature (depicts nudity or a sex
|
1357
|
-
# Sexually suggestive content is also detected.
|
1358
|
-
#
|
1359
|
-
#
|
1360
|
-
#
|
1361
|
-
#
|
1676
|
+
# the accent color, dominant color, and whether an image is black&white. Adult
|
1677
|
+
# - detects if the image is pornographic in nature (depicts nudity or a sex
|
1678
|
+
# act). Sexually suggestive content is also detected. Objects - detects
|
1679
|
+
# various objects within an image, including the approximate location. The
|
1680
|
+
# Objects argument is only available in English.
|
1681
|
+
# @param details [Array<Details>] A string indicating which domain-specific
|
1682
|
+
# details to return. Multiple values should be comma-separated. Valid visual
|
1683
|
+
# feature types include: Celebrities - identifies celebrities if detected in
|
1684
|
+
# the image, Landmarks - identifies notable landmarks in the image.
|
1362
1685
|
# @param language [Enum] The desired language for output generation. If this
|
1363
1686
|
# parameter is not specified, the default value is "en".Supported
|
1364
1687
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -1399,7 +1722,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1399
1722
|
|
1400
1723
|
options = {
|
1401
1724
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1402
|
-
query_params: {'visualFeatures' => visual_features.nil? ? nil : visual_features.join(','),'details' => details,'language' => language},
|
1725
|
+
query_params: {'visualFeatures' => visual_features.nil? ? nil : visual_features.join(','),'details' => details.nil? ? nil : details.join(','),'language' => language},
|
1403
1726
|
body: request_content,
|
1404
1727
|
headers: request_headers.merge(custom_headers || {}),
|
1405
1728
|
base_url: request_url
|
@@ -1434,82 +1757,326 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1434
1757
|
end
|
1435
1758
|
|
1436
1759
|
#
|
1437
|
-
# This operation
|
1438
|
-
#
|
1439
|
-
#
|
1440
|
-
#
|
1441
|
-
#
|
1442
|
-
#
|
1443
|
-
#
|
1444
|
-
#
|
1445
|
-
#
|
1446
|
-
# Recommended minimum of 50.
|
1447
|
-
# @param height [Integer] Height of the thumbnail. It must be between 1 and
|
1448
|
-
# 1024. Recommended minimum of 50.
|
1760
|
+
# This operation returns a bounding box around the most important area of the
|
1761
|
+
# image.
|
1762
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1763
|
+
# response contains an error code and a message to help determine what went
|
1764
|
+
# wrong.
|
1765
|
+
# Upon failure, the error code and an error message are returned. The error
|
1766
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
1767
|
+
# NotSupportedImage, FailedToProcess, Timeout, or InternalServerError.
|
1768
|
+
#
|
1449
1769
|
# @param image An image stream.
|
1450
|
-
# @param smart_cropping [Boolean] Boolean flag for enabling smart cropping.
|
1451
1770
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1452
1771
|
# will be added to the HTTP request.
|
1453
1772
|
#
|
1454
|
-
# @return [
|
1773
|
+
# @return [AreaOfInterestResult] operation results.
|
1455
1774
|
#
|
1456
|
-
def
|
1457
|
-
response =
|
1775
|
+
def get_area_of_interest_in_stream(image, custom_headers:nil)
|
1776
|
+
response = get_area_of_interest_in_stream_async(image, custom_headers:custom_headers).value!
|
1458
1777
|
response.body unless response.nil?
|
1459
1778
|
end
|
1460
1779
|
|
1461
1780
|
#
|
1462
|
-
# This operation
|
1463
|
-
#
|
1464
|
-
#
|
1465
|
-
#
|
1466
|
-
#
|
1467
|
-
#
|
1468
|
-
#
|
1469
|
-
#
|
1470
|
-
#
|
1471
|
-
#
|
1472
|
-
# @param
|
1473
|
-
#
|
1781
|
+
# This operation returns a bounding box around the most important area of the
|
1782
|
+
# image.
|
1783
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1784
|
+
# response contains an error code and a message to help determine what went
|
1785
|
+
# wrong.
|
1786
|
+
# Upon failure, the error code and an error message are returned. The error
|
1787
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
1788
|
+
# NotSupportedImage, FailedToProcess, Timeout, or InternalServerError.
|
1789
|
+
#
|
1790
|
+
# @param image An image stream.
|
1791
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1792
|
+
# will be added to the HTTP request.
|
1793
|
+
#
|
1794
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
1795
|
+
#
|
1796
|
+
def get_area_of_interest_in_stream_with_http_info(image, custom_headers:nil)
|
1797
|
+
get_area_of_interest_in_stream_async(image, custom_headers:custom_headers).value!
|
1798
|
+
end
|
1799
|
+
|
1800
|
+
#
|
1801
|
+
# This operation returns a bounding box around the most important area of the
|
1802
|
+
# image.
|
1803
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1804
|
+
# response contains an error code and a message to help determine what went
|
1805
|
+
# wrong.
|
1806
|
+
# Upon failure, the error code and an error message are returned. The error
|
1807
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
1808
|
+
# NotSupportedImage, FailedToProcess, Timeout, or InternalServerError.
|
1809
|
+
#
|
1810
|
+
# @param image An image stream.
|
1811
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1812
|
+
# to the HTTP request.
|
1813
|
+
#
|
1814
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1815
|
+
#
|
1816
|
+
def get_area_of_interest_in_stream_async(image, custom_headers:nil)
|
1817
|
+
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
1818
|
+
fail ArgumentError, 'image is nil' if image.nil?
|
1819
|
+
|
1820
|
+
|
1821
|
+
request_headers = {}
|
1822
|
+
request_headers['Content-Type'] = 'application/octet-stream'
|
1823
|
+
|
1824
|
+
# Set Headers
|
1825
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
1826
|
+
request_headers['accept-language'] = accept_language unless accept_language.nil?
|
1827
|
+
|
1828
|
+
# Serialize Request
|
1829
|
+
request_mapper = {
|
1830
|
+
client_side_validation: true,
|
1831
|
+
required: true,
|
1832
|
+
serialized_name: 'Image',
|
1833
|
+
type: {
|
1834
|
+
name: 'Stream'
|
1835
|
+
}
|
1836
|
+
}
|
1837
|
+
request_content = self.serialize(request_mapper, image)
|
1838
|
+
|
1839
|
+
path_template = 'areaOfInterest'
|
1840
|
+
|
1841
|
+
request_url = @base_url || self.base_url
|
1842
|
+
request_url = request_url.gsub('{Endpoint}', endpoint)
|
1843
|
+
|
1844
|
+
options = {
|
1845
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1846
|
+
body: request_content,
|
1847
|
+
headers: request_headers.merge(custom_headers || {}),
|
1848
|
+
base_url: request_url
|
1849
|
+
}
|
1850
|
+
promise = self.make_request_async(:post, path_template, options)
|
1851
|
+
|
1852
|
+
promise = promise.then do |result|
|
1853
|
+
http_response = result.response
|
1854
|
+
status_code = http_response.status
|
1855
|
+
response_content = http_response.body
|
1856
|
+
unless status_code == 200
|
1857
|
+
error_model = JSON.load(response_content)
|
1858
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
1859
|
+
end
|
1860
|
+
|
1861
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
1862
|
+
# Deserialize Response
|
1863
|
+
if status_code == 200
|
1864
|
+
begin
|
1865
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
1866
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::AreaOfInterestResult.mapper()
|
1867
|
+
result.body = self.deserialize(result_mapper, parsed_response)
|
1868
|
+
rescue Exception => e
|
1869
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
1870
|
+
end
|
1871
|
+
end
|
1872
|
+
|
1873
|
+
result
|
1874
|
+
end
|
1875
|
+
|
1876
|
+
promise.execute
|
1877
|
+
end
|
1878
|
+
|
1879
|
+
#
|
1880
|
+
# This operation generates a description of an image in human readable language
|
1881
|
+
# with complete sentences. The description is based on a collection of content
|
1882
|
+
# tags, which are also returned by the operation. More than one description can
|
1883
|
+
# be generated for each image. Descriptions are ordered by their confidence
|
1884
|
+
# score. All descriptions are in English.
|
1885
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
1886
|
+
# an image URL.
|
1887
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1888
|
+
# response will contain an error code and a message to help understand what
|
1889
|
+
# went wrong.
|
1890
|
+
#
|
1891
|
+
# @param image An image stream.
|
1892
|
+
# @param max_candidates [Integer] Maximum number of candidate descriptions to
|
1893
|
+
# be returned. The default is 1.
|
1894
|
+
# @param language [Enum] The desired language for output generation. If this
|
1895
|
+
# parameter is not specified, the default value is "en".Supported
|
1896
|
+
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
1897
|
+
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
1898
|
+
# 'ja', 'pt', 'zh'
|
1899
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1900
|
+
# will be added to the HTTP request.
|
1901
|
+
#
|
1902
|
+
# @return [ImageDescription] operation results.
|
1903
|
+
#
|
1904
|
+
def describe_image_in_stream(image, max_candidates:1, language:nil, custom_headers:nil)
|
1905
|
+
response = describe_image_in_stream_async(image, max_candidates:max_candidates, language:language, custom_headers:custom_headers).value!
|
1906
|
+
response.body unless response.nil?
|
1907
|
+
end
|
1908
|
+
|
1909
|
+
#
|
1910
|
+
# This operation generates a description of an image in human readable language
|
1911
|
+
# with complete sentences. The description is based on a collection of content
|
1912
|
+
# tags, which are also returned by the operation. More than one description can
|
1913
|
+
# be generated for each image. Descriptions are ordered by their confidence
|
1914
|
+
# score. All descriptions are in English.
|
1915
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
1916
|
+
# an image URL.
|
1917
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1918
|
+
# response will contain an error code and a message to help understand what
|
1919
|
+
# went wrong.
|
1920
|
+
#
|
1921
|
+
# @param image An image stream.
|
1922
|
+
# @param max_candidates [Integer] Maximum number of candidate descriptions to
|
1923
|
+
# be returned. The default is 1.
|
1924
|
+
# @param language [Enum] The desired language for output generation. If this
|
1925
|
+
# parameter is not specified, the default value is "en".Supported
|
1926
|
+
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
1927
|
+
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
1928
|
+
# 'ja', 'pt', 'zh'
|
1929
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1930
|
+
# will be added to the HTTP request.
|
1931
|
+
#
|
1932
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
1933
|
+
#
|
1934
|
+
def describe_image_in_stream_with_http_info(image, max_candidates:1, language:nil, custom_headers:nil)
|
1935
|
+
describe_image_in_stream_async(image, max_candidates:max_candidates, language:language, custom_headers:custom_headers).value!
|
1936
|
+
end
|
1937
|
+
|
1938
|
+
#
|
1939
|
+
# This operation generates a description of an image in human readable language
|
1940
|
+
# with complete sentences. The description is based on a collection of content
|
1941
|
+
# tags, which are also returned by the operation. More than one description can
|
1942
|
+
# be generated for each image. Descriptions are ordered by their confidence
|
1943
|
+
# score. All descriptions are in English.
|
1944
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
1945
|
+
# an image URL.
|
1946
|
+
# A successful response will be returned in JSON. If the request failed, the
|
1947
|
+
# response will contain an error code and a message to help understand what
|
1948
|
+
# went wrong.
|
1949
|
+
#
|
1950
|
+
# @param image An image stream.
|
1951
|
+
# @param max_candidates [Integer] Maximum number of candidate descriptions to
|
1952
|
+
# be returned. The default is 1.
|
1953
|
+
# @param language [Enum] The desired language for output generation. If this
|
1954
|
+
# parameter is not specified, the default value is "en".Supported
|
1955
|
+
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
1956
|
+
# Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es',
|
1957
|
+
# 'ja', 'pt', 'zh'
|
1958
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1959
|
+
# to the HTTP request.
|
1960
|
+
#
|
1961
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1962
|
+
#
|
1963
|
+
def describe_image_in_stream_async(image, max_candidates:1, language:nil, custom_headers:nil)
|
1964
|
+
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
1965
|
+
fail ArgumentError, 'image is nil' if image.nil?
|
1966
|
+
|
1967
|
+
|
1968
|
+
request_headers = {}
|
1969
|
+
request_headers['Content-Type'] = 'application/octet-stream'
|
1970
|
+
|
1971
|
+
# Set Headers
|
1972
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
1973
|
+
request_headers['accept-language'] = accept_language unless accept_language.nil?
|
1974
|
+
|
1975
|
+
# Serialize Request
|
1976
|
+
request_mapper = {
|
1977
|
+
client_side_validation: true,
|
1978
|
+
required: true,
|
1979
|
+
serialized_name: 'Image',
|
1980
|
+
type: {
|
1981
|
+
name: 'Stream'
|
1982
|
+
}
|
1983
|
+
}
|
1984
|
+
request_content = self.serialize(request_mapper, image)
|
1985
|
+
|
1986
|
+
path_template = 'describe'
|
1987
|
+
|
1988
|
+
request_url = @base_url || self.base_url
|
1989
|
+
request_url = request_url.gsub('{Endpoint}', endpoint)
|
1990
|
+
|
1991
|
+
options = {
|
1992
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1993
|
+
query_params: {'maxCandidates' => max_candidates,'language' => language},
|
1994
|
+
body: request_content,
|
1995
|
+
headers: request_headers.merge(custom_headers || {}),
|
1996
|
+
base_url: request_url
|
1997
|
+
}
|
1998
|
+
promise = self.make_request_async(:post, path_template, options)
|
1999
|
+
|
2000
|
+
promise = promise.then do |result|
|
2001
|
+
http_response = result.response
|
2002
|
+
status_code = http_response.status
|
2003
|
+
response_content = http_response.body
|
2004
|
+
unless status_code == 200
|
2005
|
+
error_model = JSON.load(response_content)
|
2006
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
2007
|
+
end
|
2008
|
+
|
2009
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
2010
|
+
# Deserialize Response
|
2011
|
+
if status_code == 200
|
2012
|
+
begin
|
2013
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
2014
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::ImageDescription.mapper()
|
2015
|
+
result.body = self.deserialize(result_mapper, parsed_response)
|
2016
|
+
rescue Exception => e
|
2017
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
2018
|
+
end
|
2019
|
+
end
|
2020
|
+
|
2021
|
+
result
|
2022
|
+
end
|
2023
|
+
|
2024
|
+
promise.execute
|
2025
|
+
end
|
2026
|
+
|
2027
|
+
#
|
2028
|
+
# Performs object detection on the specified image.
|
2029
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
2030
|
+
# an image URL.
|
2031
|
+
# A successful response will be returned in JSON. If the request failed, the
|
2032
|
+
# response will contain an error code and a message to help understand what
|
2033
|
+
# went wrong.
|
2034
|
+
#
|
2035
|
+
# @param image An image stream.
|
2036
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
2037
|
+
# will be added to the HTTP request.
|
2038
|
+
#
|
2039
|
+
# @return [DetectResult] operation results.
|
2040
|
+
#
|
2041
|
+
def detect_objects_in_stream(image, custom_headers:nil)
|
2042
|
+
response = detect_objects_in_stream_async(image, custom_headers:custom_headers).value!
|
2043
|
+
response.body unless response.nil?
|
2044
|
+
end
|
2045
|
+
|
2046
|
+
#
|
2047
|
+
# Performs object detection on the specified image.
|
2048
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
2049
|
+
# an image URL.
|
2050
|
+
# A successful response will be returned in JSON. If the request failed, the
|
2051
|
+
# response will contain an error code and a message to help understand what
|
2052
|
+
# went wrong.
|
2053
|
+
#
|
1474
2054
|
# @param image An image stream.
|
1475
|
-
# @param smart_cropping [Boolean] Boolean flag for enabling smart cropping.
|
1476
2055
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1477
2056
|
# will be added to the HTTP request.
|
1478
2057
|
#
|
1479
2058
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
1480
2059
|
#
|
1481
|
-
def
|
1482
|
-
|
2060
|
+
def detect_objects_in_stream_with_http_info(image, custom_headers:nil)
|
2061
|
+
detect_objects_in_stream_async(image, custom_headers:custom_headers).value!
|
1483
2062
|
end
|
1484
2063
|
|
1485
2064
|
#
|
1486
|
-
#
|
1487
|
-
#
|
1488
|
-
#
|
1489
|
-
#
|
1490
|
-
#
|
1491
|
-
#
|
1492
|
-
#
|
1493
|
-
#
|
1494
|
-
# @param width [Integer] Width of the thumbnail. It must be between 1 and 1024.
|
1495
|
-
# Recommended minimum of 50.
|
1496
|
-
# @param height [Integer] Height of the thumbnail. It must be between 1 and
|
1497
|
-
# 1024. Recommended minimum of 50.
|
2065
|
+
# Performs object detection on the specified image.
|
2066
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
2067
|
+
# an image URL.
|
2068
|
+
# A successful response will be returned in JSON. If the request failed, the
|
2069
|
+
# response will contain an error code and a message to help understand what
|
2070
|
+
# went wrong.
|
2071
|
+
#
|
1498
2072
|
# @param image An image stream.
|
1499
|
-
# @param smart_cropping [Boolean] Boolean flag for enabling smart cropping.
|
1500
2073
|
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1501
2074
|
# to the HTTP request.
|
1502
2075
|
#
|
1503
2076
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1504
2077
|
#
|
1505
|
-
def
|
2078
|
+
def detect_objects_in_stream_async(image, custom_headers:nil)
|
1506
2079
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
1507
|
-
fail ArgumentError, 'width is nil' if width.nil?
|
1508
|
-
fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMaximum': '1023'" if !width.nil? && width > 1023
|
1509
|
-
fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMinimum': '1'" if !width.nil? && width < 1
|
1510
|
-
fail ArgumentError, 'height is nil' if height.nil?
|
1511
|
-
fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMaximum': '1023'" if !height.nil? && height > 1023
|
1512
|
-
fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMinimum': '1'" if !height.nil? && height < 1
|
1513
2080
|
fail ArgumentError, 'image is nil' if image.nil?
|
1514
2081
|
|
1515
2082
|
|
@@ -1531,14 +2098,13 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1531
2098
|
}
|
1532
2099
|
request_content = self.serialize(request_mapper, image)
|
1533
2100
|
|
1534
|
-
path_template = '
|
2101
|
+
path_template = 'detect'
|
1535
2102
|
|
1536
2103
|
request_url = @base_url || self.base_url
|
1537
2104
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
1538
2105
|
|
1539
2106
|
options = {
|
1540
2107
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1541
|
-
query_params: {'width' => width,'height' => height,'smartCropping' => smart_cropping},
|
1542
2108
|
body: request_content,
|
1543
2109
|
headers: request_headers.merge(custom_headers || {}),
|
1544
2110
|
base_url: request_url
|
@@ -1551,7 +2117,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1551
2117
|
response_content = http_response.body
|
1552
2118
|
unless status_code == 200
|
1553
2119
|
error_model = JSON.load(response_content)
|
1554
|
-
fail
|
2120
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
1555
2121
|
end
|
1556
2122
|
|
1557
2123
|
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
@@ -1559,14 +2125,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1559
2125
|
if status_code == 200
|
1560
2126
|
begin
|
1561
2127
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
1562
|
-
result_mapper =
|
1563
|
-
client_side_validation: true,
|
1564
|
-
required: false,
|
1565
|
-
serialized_name: 'parsed_response',
|
1566
|
-
type: {
|
1567
|
-
name: 'Stream'
|
1568
|
-
}
|
1569
|
-
}
|
2128
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::DetectResult.mapper()
|
1570
2129
|
result.body = self.deserialize(result_mapper, parsed_response)
|
1571
2130
|
rescue Exception => e
|
1572
2131
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -1580,86 +2139,97 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1580
2139
|
end
|
1581
2140
|
|
1582
2141
|
#
|
1583
|
-
#
|
1584
|
-
#
|
1585
|
-
#
|
1586
|
-
#
|
1587
|
-
#
|
1588
|
-
#
|
1589
|
-
#
|
1590
|
-
#
|
1591
|
-
# the
|
1592
|
-
#
|
1593
|
-
#
|
2142
|
+
# This operation generates a thumbnail image with the user-specified width and
|
2143
|
+
# height. By default, the service analyzes the image, identifies the region of
|
2144
|
+
# interest (ROI), and generates smart cropping coordinates based on the ROI.
|
2145
|
+
# Smart cropping helps when you specify an aspect ratio that differs from that
|
2146
|
+
# of the input image.
|
2147
|
+
# A successful response contains the thumbnail image binary. If the request
|
2148
|
+
# failed, the response contains an error code and a message to help determine
|
2149
|
+
# what went wrong.
|
2150
|
+
# Upon failure, the error code and an error message are returned. The error
|
2151
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
2152
|
+
# InvalidThumbnailSize, NotSupportedImage, FailedToProcess, Timeout, or
|
2153
|
+
# InternalServerError.
|
2154
|
+
#
|
2155
|
+
# @param width [Integer] Width of the thumbnail, in pixels. It must be between
|
2156
|
+
# 1 and 1024. Recommended minimum of 50.
|
2157
|
+
# @param height [Integer] Height of the thumbnail, in pixels. It must be
|
2158
|
+
# between 1 and 1024. Recommended minimum of 50.
|
1594
2159
|
# @param image An image stream.
|
1595
|
-
# @param
|
1596
|
-
# detected in the image. The default value is 'unk'. Possible values include:
|
1597
|
-
# 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el',
|
1598
|
-
# 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', 'ar', 'ro',
|
1599
|
-
# 'sr-Cyrl', 'sr-Latn', 'sk'
|
2160
|
+
# @param smart_cropping [Boolean] Boolean flag for enabling smart cropping.
|
1600
2161
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1601
2162
|
# will be added to the HTTP request.
|
1602
2163
|
#
|
1603
|
-
# @return [
|
2164
|
+
# @return [NOT_IMPLEMENTED] operation results.
|
1604
2165
|
#
|
1605
|
-
def
|
1606
|
-
response =
|
2166
|
+
def generate_thumbnail_in_stream(width, height, image, smart_cropping:false, custom_headers:nil)
|
2167
|
+
response = generate_thumbnail_in_stream_async(width, height, image, smart_cropping:smart_cropping, custom_headers:custom_headers).value!
|
1607
2168
|
response.body unless response.nil?
|
1608
2169
|
end
|
1609
2170
|
|
1610
2171
|
#
|
1611
|
-
#
|
1612
|
-
#
|
1613
|
-
#
|
1614
|
-
#
|
1615
|
-
#
|
1616
|
-
#
|
1617
|
-
#
|
1618
|
-
#
|
1619
|
-
# the
|
1620
|
-
#
|
1621
|
-
#
|
2172
|
+
# This operation generates a thumbnail image with the user-specified width and
|
2173
|
+
# height. By default, the service analyzes the image, identifies the region of
|
2174
|
+
# interest (ROI), and generates smart cropping coordinates based on the ROI.
|
2175
|
+
# Smart cropping helps when you specify an aspect ratio that differs from that
|
2176
|
+
# of the input image.
|
2177
|
+
# A successful response contains the thumbnail image binary. If the request
|
2178
|
+
# failed, the response contains an error code and a message to help determine
|
2179
|
+
# what went wrong.
|
2180
|
+
# Upon failure, the error code and an error message are returned. The error
|
2181
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
2182
|
+
# InvalidThumbnailSize, NotSupportedImage, FailedToProcess, Timeout, or
|
2183
|
+
# InternalServerError.
|
2184
|
+
#
|
2185
|
+
# @param width [Integer] Width of the thumbnail, in pixels. It must be between
|
2186
|
+
# 1 and 1024. Recommended minimum of 50.
|
2187
|
+
# @param height [Integer] Height of the thumbnail, in pixels. It must be
|
2188
|
+
# between 1 and 1024. Recommended minimum of 50.
|
1622
2189
|
# @param image An image stream.
|
1623
|
-
# @param
|
1624
|
-
# detected in the image. The default value is 'unk'. Possible values include:
|
1625
|
-
# 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el',
|
1626
|
-
# 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', 'ar', 'ro',
|
1627
|
-
# 'sr-Cyrl', 'sr-Latn', 'sk'
|
2190
|
+
# @param smart_cropping [Boolean] Boolean flag for enabling smart cropping.
|
1628
2191
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1629
2192
|
# will be added to the HTTP request.
|
1630
2193
|
#
|
1631
2194
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
1632
2195
|
#
|
1633
|
-
def
|
1634
|
-
|
2196
|
+
def generate_thumbnail_in_stream_with_http_info(width, height, image, smart_cropping:false, custom_headers:nil)
|
2197
|
+
generate_thumbnail_in_stream_async(width, height, image, smart_cropping:smart_cropping, custom_headers:custom_headers).value!
|
1635
2198
|
end
|
1636
2199
|
|
1637
2200
|
#
|
1638
|
-
#
|
1639
|
-
#
|
1640
|
-
#
|
1641
|
-
#
|
1642
|
-
#
|
1643
|
-
#
|
1644
|
-
#
|
1645
|
-
#
|
1646
|
-
# the
|
1647
|
-
#
|
1648
|
-
#
|
2201
|
+
# This operation generates a thumbnail image with the user-specified width and
|
2202
|
+
# height. By default, the service analyzes the image, identifies the region of
|
2203
|
+
# interest (ROI), and generates smart cropping coordinates based on the ROI.
|
2204
|
+
# Smart cropping helps when you specify an aspect ratio that differs from that
|
2205
|
+
# of the input image.
|
2206
|
+
# A successful response contains the thumbnail image binary. If the request
|
2207
|
+
# failed, the response contains an error code and a message to help determine
|
2208
|
+
# what went wrong.
|
2209
|
+
# Upon failure, the error code and an error message are returned. The error
|
2210
|
+
# code could be one of InvalidImageUrl, InvalidImageFormat, InvalidImageSize,
|
2211
|
+
# InvalidThumbnailSize, NotSupportedImage, FailedToProcess, Timeout, or
|
2212
|
+
# InternalServerError.
|
2213
|
+
#
|
2214
|
+
# @param width [Integer] Width of the thumbnail, in pixels. It must be between
|
2215
|
+
# 1 and 1024. Recommended minimum of 50.
|
2216
|
+
# @param height [Integer] Height of the thumbnail, in pixels. It must be
|
2217
|
+
# between 1 and 1024. Recommended minimum of 50.
|
1649
2218
|
# @param image An image stream.
|
1650
|
-
# @param
|
1651
|
-
# detected in the image. The default value is 'unk'. Possible values include:
|
1652
|
-
# 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el',
|
1653
|
-
# 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', 'ar', 'ro',
|
1654
|
-
# 'sr-Cyrl', 'sr-Latn', 'sk'
|
2219
|
+
# @param smart_cropping [Boolean] Boolean flag for enabling smart cropping.
|
1655
2220
|
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1656
2221
|
# to the HTTP request.
|
1657
2222
|
#
|
1658
2223
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1659
2224
|
#
|
1660
|
-
def
|
2225
|
+
def generate_thumbnail_in_stream_async(width, height, image, smart_cropping:false, custom_headers:nil)
|
1661
2226
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
1662
|
-
fail ArgumentError, '
|
2227
|
+
fail ArgumentError, 'width is nil' if width.nil?
|
2228
|
+
fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMaximum': '1024'" if !width.nil? && width > 1024
|
2229
|
+
fail ArgumentError, "'width' should satisfy the constraint - 'InclusiveMinimum': '1'" if !width.nil? && width < 1
|
2230
|
+
fail ArgumentError, 'height is nil' if height.nil?
|
2231
|
+
fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMaximum': '1024'" if !height.nil? && height > 1024
|
2232
|
+
fail ArgumentError, "'height' should satisfy the constraint - 'InclusiveMinimum': '1'" if !height.nil? && height < 1
|
1663
2233
|
fail ArgumentError, 'image is nil' if image.nil?
|
1664
2234
|
|
1665
2235
|
|
@@ -1681,14 +2251,14 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1681
2251
|
}
|
1682
2252
|
request_content = self.serialize(request_mapper, image)
|
1683
2253
|
|
1684
|
-
path_template = '
|
2254
|
+
path_template = 'generateThumbnail'
|
1685
2255
|
|
1686
2256
|
request_url = @base_url || self.base_url
|
1687
2257
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
1688
2258
|
|
1689
2259
|
options = {
|
1690
2260
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1691
|
-
query_params: {'
|
2261
|
+
query_params: {'width' => width,'height' => height,'smartCropping' => smart_cropping},
|
1692
2262
|
body: request_content,
|
1693
2263
|
headers: request_headers.merge(custom_headers || {}),
|
1694
2264
|
base_url: request_url
|
@@ -1701,7 +2271,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1701
2271
|
response_content = http_response.body
|
1702
2272
|
unless status_code == 200
|
1703
2273
|
error_model = JSON.load(response_content)
|
1704
|
-
fail
|
2274
|
+
fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
|
1705
2275
|
end
|
1706
2276
|
|
1707
2277
|
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
@@ -1709,7 +2279,14 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1709
2279
|
if status_code == 200
|
1710
2280
|
begin
|
1711
2281
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
1712
|
-
result_mapper =
|
2282
|
+
result_mapper = {
|
2283
|
+
client_side_validation: true,
|
2284
|
+
required: false,
|
2285
|
+
serialized_name: 'parsed_response',
|
2286
|
+
type: {
|
2287
|
+
name: 'Stream'
|
2288
|
+
}
|
2289
|
+
}
|
1713
2290
|
result.body = self.deserialize(result_mapper, parsed_response)
|
1714
2291
|
rescue Exception => e
|
1715
2292
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -1723,18 +2300,19 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1723
2300
|
end
|
1724
2301
|
|
1725
2302
|
#
|
1726
|
-
# This operation
|
1727
|
-
#
|
1728
|
-
#
|
1729
|
-
#
|
1730
|
-
#
|
1731
|
-
# (1) Uploading an image or (2) specifying
|
1732
|
-
#
|
1733
|
-
#
|
2303
|
+
# This operation recognizes content within an image by applying a
|
2304
|
+
# domain-specific model. The list of domain-specific models that are supported
|
2305
|
+
# by the Computer Vision API can be retrieved using the /models GET request.
|
2306
|
+
# Currently, the API provides following domain-specific models: celebrities,
|
2307
|
+
# landmarks.
|
2308
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
2309
|
+
# an image URL.
|
2310
|
+
# A successful response will be returned in JSON.
|
2311
|
+
# If the request failed, the response will contain an error code and a message
|
2312
|
+
# to help understand what went wrong.
|
1734
2313
|
#
|
2314
|
+
# @param model [String] The domain-specific content to recognize.
|
1735
2315
|
# @param image An image stream.
|
1736
|
-
# @param max_candidates [String] Maximum number of candidate descriptions to be
|
1737
|
-
# returned. The default is 1.
|
1738
2316
|
# @param language [Enum] The desired language for output generation. If this
|
1739
2317
|
# parameter is not specified, the default value is "en".Supported
|
1740
2318
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -1743,26 +2321,27 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1743
2321
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1744
2322
|
# will be added to the HTTP request.
|
1745
2323
|
#
|
1746
|
-
# @return [
|
2324
|
+
# @return [DomainModelResults] operation results.
|
1747
2325
|
#
|
1748
|
-
def
|
1749
|
-
response =
|
2326
|
+
def analyze_image_by_domain_in_stream(model, image, language:nil, custom_headers:nil)
|
2327
|
+
response = analyze_image_by_domain_in_stream_async(model, image, language:language, custom_headers:custom_headers).value!
|
1750
2328
|
response.body unless response.nil?
|
1751
2329
|
end
|
1752
2330
|
|
1753
2331
|
#
|
1754
|
-
# This operation
|
1755
|
-
#
|
1756
|
-
#
|
1757
|
-
#
|
1758
|
-
#
|
1759
|
-
# (1) Uploading an image or (2) specifying
|
1760
|
-
#
|
1761
|
-
#
|
2332
|
+
# This operation recognizes content within an image by applying a
|
2333
|
+
# domain-specific model. The list of domain-specific models that are supported
|
2334
|
+
# by the Computer Vision API can be retrieved using the /models GET request.
|
2335
|
+
# Currently, the API provides following domain-specific models: celebrities,
|
2336
|
+
# landmarks.
|
2337
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
2338
|
+
# an image URL.
|
2339
|
+
# A successful response will be returned in JSON.
|
2340
|
+
# If the request failed, the response will contain an error code and a message
|
2341
|
+
# to help understand what went wrong.
|
1762
2342
|
#
|
2343
|
+
# @param model [String] The domain-specific content to recognize.
|
1763
2344
|
# @param image An image stream.
|
1764
|
-
# @param max_candidates [String] Maximum number of candidate descriptions to be
|
1765
|
-
# returned. The default is 1.
|
1766
2345
|
# @param language [Enum] The desired language for output generation. If this
|
1767
2346
|
# parameter is not specified, the default value is "en".Supported
|
1768
2347
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -1773,23 +2352,24 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1773
2352
|
#
|
1774
2353
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
1775
2354
|
#
|
1776
|
-
def
|
1777
|
-
|
2355
|
+
def analyze_image_by_domain_in_stream_with_http_info(model, image, language:nil, custom_headers:nil)
|
2356
|
+
analyze_image_by_domain_in_stream_async(model, image, language:language, custom_headers:custom_headers).value!
|
1778
2357
|
end
|
1779
2358
|
|
1780
2359
|
#
|
1781
|
-
# This operation
|
1782
|
-
#
|
1783
|
-
#
|
1784
|
-
#
|
1785
|
-
#
|
1786
|
-
# (1) Uploading an image or (2) specifying
|
1787
|
-
#
|
1788
|
-
#
|
2360
|
+
# This operation recognizes content within an image by applying a
|
2361
|
+
# domain-specific model. The list of domain-specific models that are supported
|
2362
|
+
# by the Computer Vision API can be retrieved using the /models GET request.
|
2363
|
+
# Currently, the API provides following domain-specific models: celebrities,
|
2364
|
+
# landmarks.
|
2365
|
+
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
2366
|
+
# an image URL.
|
2367
|
+
# A successful response will be returned in JSON.
|
2368
|
+
# If the request failed, the response will contain an error code and a message
|
2369
|
+
# to help understand what went wrong.
|
1789
2370
|
#
|
2371
|
+
# @param model [String] The domain-specific content to recognize.
|
1790
2372
|
# @param image An image stream.
|
1791
|
-
# @param max_candidates [String] Maximum number of candidate descriptions to be
|
1792
|
-
# returned. The default is 1.
|
1793
2373
|
# @param language [Enum] The desired language for output generation. If this
|
1794
2374
|
# parameter is not specified, the default value is "en".Supported
|
1795
2375
|
# languages:en - English, Default. es - Spanish, ja - Japanese, pt -
|
@@ -1800,8 +2380,9 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1800
2380
|
#
|
1801
2381
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1802
2382
|
#
|
1803
|
-
def
|
2383
|
+
def analyze_image_by_domain_in_stream_async(model, image, language:nil, custom_headers:nil)
|
1804
2384
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
2385
|
+
fail ArgumentError, 'model is nil' if model.nil?
|
1805
2386
|
fail ArgumentError, 'image is nil' if image.nil?
|
1806
2387
|
|
1807
2388
|
|
@@ -1823,14 +2404,15 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1823
2404
|
}
|
1824
2405
|
request_content = self.serialize(request_mapper, image)
|
1825
2406
|
|
1826
|
-
path_template = '
|
2407
|
+
path_template = 'models/{model}/analyze'
|
1827
2408
|
|
1828
2409
|
request_url = @base_url || self.base_url
|
1829
2410
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
1830
2411
|
|
1831
2412
|
options = {
|
1832
2413
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1833
|
-
|
2414
|
+
path_params: {'model' => model},
|
2415
|
+
query_params: {'language' => language},
|
1834
2416
|
body: request_content,
|
1835
2417
|
headers: request_headers.merge(custom_headers || {}),
|
1836
2418
|
base_url: request_url
|
@@ -1851,7 +2433,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1851
2433
|
if status_code == 200
|
1852
2434
|
begin
|
1853
2435
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
1854
|
-
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::
|
2436
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::DomainModelResults.mapper()
|
1855
2437
|
result.body = self.deserialize(result_mapper, parsed_response)
|
1856
2438
|
rescue Exception => e
|
1857
2439
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -1865,76 +2447,89 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1865
2447
|
end
|
1866
2448
|
|
1867
2449
|
#
|
1868
|
-
#
|
1869
|
-
#
|
1870
|
-
#
|
1871
|
-
#
|
1872
|
-
#
|
1873
|
-
#
|
1874
|
-
#
|
2450
|
+
# Optical Character Recognition (OCR) detects text in an image and extracts the
|
2451
|
+
# recognized characters into a machine-usable character stream.
|
2452
|
+
# Upon success, the OCR results will be returned.
|
2453
|
+
# Upon failure, the error code together with an error message will be returned.
|
2454
|
+
# The error code can be one of InvalidImageUrl, InvalidImageFormat,
|
2455
|
+
# InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or
|
2456
|
+
# InternalServerError.
|
1875
2457
|
#
|
2458
|
+
# @param detect_orientation [Boolean] Whether detect the text orientation in
|
2459
|
+
# the image. With detectOrientation=true the OCR service tries to detect the
|
2460
|
+
# image orientation and correct it before further processing (e.g. if it's
|
2461
|
+
# upside-down).
|
1876
2462
|
# @param image An image stream.
|
1877
|
-
# @param language [
|
1878
|
-
#
|
1879
|
-
#
|
1880
|
-
#
|
1881
|
-
# '
|
2463
|
+
# @param language [OcrLanguages] The BCP-47 language code of the text to be
|
2464
|
+
# detected in the image. The default value is 'unk'. Possible values include:
|
2465
|
+
# 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el',
|
2466
|
+
# 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', 'ar', 'ro',
|
2467
|
+
# 'sr-Cyrl', 'sr-Latn', 'sk'
|
1882
2468
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1883
2469
|
# will be added to the HTTP request.
|
1884
2470
|
#
|
1885
|
-
# @return [
|
2471
|
+
# @return [OcrResult] operation results.
|
1886
2472
|
#
|
1887
|
-
def
|
1888
|
-
response =
|
2473
|
+
def recognize_printed_text_in_stream(detect_orientation, image, language:nil, custom_headers:nil)
|
2474
|
+
response = recognize_printed_text_in_stream_async(detect_orientation, image, language:language, custom_headers:custom_headers).value!
|
1889
2475
|
response.body unless response.nil?
|
1890
2476
|
end
|
1891
2477
|
|
1892
2478
|
#
|
1893
|
-
#
|
1894
|
-
#
|
1895
|
-
#
|
1896
|
-
#
|
1897
|
-
#
|
1898
|
-
#
|
1899
|
-
#
|
2479
|
+
# Optical Character Recognition (OCR) detects text in an image and extracts the
|
2480
|
+
# recognized characters into a machine-usable character stream.
|
2481
|
+
# Upon success, the OCR results will be returned.
|
2482
|
+
# Upon failure, the error code together with an error message will be returned.
|
2483
|
+
# The error code can be one of InvalidImageUrl, InvalidImageFormat,
|
2484
|
+
# InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or
|
2485
|
+
# InternalServerError.
|
1900
2486
|
#
|
2487
|
+
# @param detect_orientation [Boolean] Whether detect the text orientation in
|
2488
|
+
# the image. With detectOrientation=true the OCR service tries to detect the
|
2489
|
+
# image orientation and correct it before further processing (e.g. if it's
|
2490
|
+
# upside-down).
|
1901
2491
|
# @param image An image stream.
|
1902
|
-
# @param language [
|
1903
|
-
#
|
1904
|
-
#
|
1905
|
-
#
|
1906
|
-
# '
|
2492
|
+
# @param language [OcrLanguages] The BCP-47 language code of the text to be
|
2493
|
+
# detected in the image. The default value is 'unk'. Possible values include:
|
2494
|
+
# 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el',
|
2495
|
+
# 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', 'ar', 'ro',
|
2496
|
+
# 'sr-Cyrl', 'sr-Latn', 'sk'
|
1907
2497
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1908
2498
|
# will be added to the HTTP request.
|
1909
2499
|
#
|
1910
2500
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
1911
2501
|
#
|
1912
|
-
def
|
1913
|
-
|
2502
|
+
def recognize_printed_text_in_stream_with_http_info(detect_orientation, image, language:nil, custom_headers:nil)
|
2503
|
+
recognize_printed_text_in_stream_async(detect_orientation, image, language:language, custom_headers:custom_headers).value!
|
1914
2504
|
end
|
1915
2505
|
|
1916
2506
|
#
|
1917
|
-
#
|
1918
|
-
#
|
1919
|
-
#
|
1920
|
-
#
|
1921
|
-
#
|
1922
|
-
#
|
1923
|
-
#
|
2507
|
+
# Optical Character Recognition (OCR) detects text in an image and extracts the
|
2508
|
+
# recognized characters into a machine-usable character stream.
|
2509
|
+
# Upon success, the OCR results will be returned.
|
2510
|
+
# Upon failure, the error code together with an error message will be returned.
|
2511
|
+
# The error code can be one of InvalidImageUrl, InvalidImageFormat,
|
2512
|
+
# InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or
|
2513
|
+
# InternalServerError.
|
1924
2514
|
#
|
2515
|
+
# @param detect_orientation [Boolean] Whether detect the text orientation in
|
2516
|
+
# the image. With detectOrientation=true the OCR service tries to detect the
|
2517
|
+
# image orientation and correct it before further processing (e.g. if it's
|
2518
|
+
# upside-down).
|
1925
2519
|
# @param image An image stream.
|
1926
|
-
# @param language [
|
1927
|
-
#
|
1928
|
-
#
|
1929
|
-
#
|
1930
|
-
# '
|
2520
|
+
# @param language [OcrLanguages] The BCP-47 language code of the text to be
|
2521
|
+
# detected in the image. The default value is 'unk'. Possible values include:
|
2522
|
+
# 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el',
|
2523
|
+
# 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', 'ar', 'ro',
|
2524
|
+
# 'sr-Cyrl', 'sr-Latn', 'sk'
|
1931
2525
|
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1932
2526
|
# to the HTTP request.
|
1933
2527
|
#
|
1934
2528
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1935
2529
|
#
|
1936
|
-
def
|
2530
|
+
def recognize_printed_text_in_stream_async(detect_orientation, image, language:nil, custom_headers:nil)
|
1937
2531
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
2532
|
+
fail ArgumentError, 'detect_orientation is nil' if detect_orientation.nil?
|
1938
2533
|
fail ArgumentError, 'image is nil' if image.nil?
|
1939
2534
|
|
1940
2535
|
|
@@ -1956,14 +2551,14 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1956
2551
|
}
|
1957
2552
|
request_content = self.serialize(request_mapper, image)
|
1958
2553
|
|
1959
|
-
path_template = '
|
2554
|
+
path_template = 'ocr'
|
1960
2555
|
|
1961
2556
|
request_url = @base_url || self.base_url
|
1962
2557
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
1963
2558
|
|
1964
2559
|
options = {
|
1965
2560
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1966
|
-
query_params: {'language' => language},
|
2561
|
+
query_params: {'detectOrientation' => detect_orientation,'language' => language},
|
1967
2562
|
body: request_content,
|
1968
2563
|
headers: request_headers.merge(custom_headers || {}),
|
1969
2564
|
base_url: request_url
|
@@ -1984,7 +2579,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1984
2579
|
if status_code == 200
|
1985
2580
|
begin
|
1986
2581
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
1987
|
-
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::
|
2582
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::OcrResult.mapper()
|
1988
2583
|
result.body = self.deserialize(result_mapper, parsed_response)
|
1989
2584
|
rescue Exception => e
|
1990
2585
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -1998,16 +2593,19 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
1998
2593
|
end
|
1999
2594
|
|
2000
2595
|
#
|
2001
|
-
# This operation
|
2002
|
-
#
|
2003
|
-
#
|
2004
|
-
#
|
2596
|
+
# This operation generates a list of words, or tags, that are relevant to the
|
2597
|
+
# content of the supplied image. The Computer Vision API can return tags based
|
2598
|
+
# on objects, living beings, scenery or actions found in images. Unlike
|
2599
|
+
# categories, tags are not organized according to a hierarchical classification
|
2600
|
+
# system, but correspond to image content. Tags may contain hints to avoid
|
2601
|
+
# ambiguity or provide context, for example the tag "cello" may be accompanied
|
2602
|
+
# by the hint "musical instrument". All tags are in English.
|
2005
2603
|
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
2006
|
-
# an image URL.
|
2007
|
-
#
|
2008
|
-
# understand what
|
2604
|
+
# an image URL.
|
2605
|
+
# A successful response will be returned in JSON. If the request failed, the
|
2606
|
+
# response will contain an error code and a message to help understand what
|
2607
|
+
# went wrong.
|
2009
2608
|
#
|
2010
|
-
# @param model [String] The domain-specific content to recognize.
|
2011
2609
|
# @param image An image stream.
|
2012
2610
|
# @param language [Enum] The desired language for output generation. If this
|
2013
2611
|
# parameter is not specified, the default value is "en".Supported
|
@@ -2017,24 +2615,27 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
2017
2615
|
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
2018
2616
|
# will be added to the HTTP request.
|
2019
2617
|
#
|
2020
|
-
# @return [
|
2618
|
+
# @return [TagResult] operation results.
|
2021
2619
|
#
|
2022
|
-
def
|
2023
|
-
response =
|
2620
|
+
def tag_image_in_stream(image, language:nil, custom_headers:nil)
|
2621
|
+
response = tag_image_in_stream_async(image, language:language, custom_headers:custom_headers).value!
|
2024
2622
|
response.body unless response.nil?
|
2025
2623
|
end
|
2026
2624
|
|
2027
2625
|
#
|
2028
|
-
# This operation
|
2029
|
-
#
|
2030
|
-
#
|
2031
|
-
#
|
2626
|
+
# This operation generates a list of words, or tags, that are relevant to the
|
2627
|
+
# content of the supplied image. The Computer Vision API can return tags based
|
2628
|
+
# on objects, living beings, scenery or actions found in images. Unlike
|
2629
|
+
# categories, tags are not organized according to a hierarchical classification
|
2630
|
+
# system, but correspond to image content. Tags may contain hints to avoid
|
2631
|
+
# ambiguity or provide context, for example the tag "cello" may be accompanied
|
2632
|
+
# by the hint "musical instrument". All tags are in English.
|
2032
2633
|
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
2033
|
-
# an image URL.
|
2034
|
-
#
|
2035
|
-
# understand what
|
2634
|
+
# an image URL.
|
2635
|
+
# A successful response will be returned in JSON. If the request failed, the
|
2636
|
+
# response will contain an error code and a message to help understand what
|
2637
|
+
# went wrong.
|
2036
2638
|
#
|
2037
|
-
# @param model [String] The domain-specific content to recognize.
|
2038
2639
|
# @param image An image stream.
|
2039
2640
|
# @param language [Enum] The desired language for output generation. If this
|
2040
2641
|
# parameter is not specified, the default value is "en".Supported
|
@@ -2046,21 +2647,24 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
2046
2647
|
#
|
2047
2648
|
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
2048
2649
|
#
|
2049
|
-
def
|
2050
|
-
|
2650
|
+
def tag_image_in_stream_with_http_info(image, language:nil, custom_headers:nil)
|
2651
|
+
tag_image_in_stream_async(image, language:language, custom_headers:custom_headers).value!
|
2051
2652
|
end
|
2052
2653
|
|
2053
2654
|
#
|
2054
|
-
# This operation
|
2055
|
-
#
|
2056
|
-
#
|
2057
|
-
#
|
2655
|
+
# This operation generates a list of words, or tags, that are relevant to the
|
2656
|
+
# content of the supplied image. The Computer Vision API can return tags based
|
2657
|
+
# on objects, living beings, scenery or actions found in images. Unlike
|
2658
|
+
# categories, tags are not organized according to a hierarchical classification
|
2659
|
+
# system, but correspond to image content. Tags may contain hints to avoid
|
2660
|
+
# ambiguity or provide context, for example the tag "cello" may be accompanied
|
2661
|
+
# by the hint "musical instrument". All tags are in English.
|
2058
2662
|
# Two input methods are supported -- (1) Uploading an image or (2) specifying
|
2059
|
-
# an image URL.
|
2060
|
-
#
|
2061
|
-
# understand what
|
2663
|
+
# an image URL.
|
2664
|
+
# A successful response will be returned in JSON. If the request failed, the
|
2665
|
+
# response will contain an error code and a message to help understand what
|
2666
|
+
# went wrong.
|
2062
2667
|
#
|
2063
|
-
# @param model [String] The domain-specific content to recognize.
|
2064
2668
|
# @param image An image stream.
|
2065
2669
|
# @param language [Enum] The desired language for output generation. If this
|
2066
2670
|
# parameter is not specified, the default value is "en".Supported
|
@@ -2072,9 +2676,8 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
2072
2676
|
#
|
2073
2677
|
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
2074
2678
|
#
|
2075
|
-
def
|
2679
|
+
def tag_image_in_stream_async(image, language:nil, custom_headers:nil)
|
2076
2680
|
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
2077
|
-
fail ArgumentError, 'model is nil' if model.nil?
|
2078
2681
|
fail ArgumentError, 'image is nil' if image.nil?
|
2079
2682
|
|
2080
2683
|
|
@@ -2096,14 +2699,13 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
2096
2699
|
}
|
2097
2700
|
request_content = self.serialize(request_mapper, image)
|
2098
2701
|
|
2099
|
-
path_template = '
|
2702
|
+
path_template = 'tag'
|
2100
2703
|
|
2101
2704
|
request_url = @base_url || self.base_url
|
2102
2705
|
request_url = request_url.gsub('{Endpoint}', endpoint)
|
2103
2706
|
|
2104
2707
|
options = {
|
2105
2708
|
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
2106
|
-
path_params: {'model' => model},
|
2107
2709
|
query_params: {'language' => language},
|
2108
2710
|
body: request_content,
|
2109
2711
|
headers: request_headers.merge(custom_headers || {}),
|
@@ -2125,7 +2727,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
2125
2727
|
if status_code == 200
|
2126
2728
|
begin
|
2127
2729
|
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
2128
|
-
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::
|
2730
|
+
result_mapper = Azure::CognitiveServices::ComputerVision::V2_0::Models::TagResult.mapper()
|
2129
2731
|
result.body = self.deserialize(result_mapper, parsed_response)
|
2130
2732
|
rescue Exception => e
|
2131
2733
|
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
@@ -2250,7 +2852,7 @@ module Azure::CognitiveServices::ComputerVision::V2_0
|
|
2250
2852
|
#
|
2251
2853
|
def add_telemetry
|
2252
2854
|
sdk_information = 'azure_cognitiveservices_computervision'
|
2253
|
-
sdk_information = "#{sdk_information}/0.
|
2855
|
+
sdk_information = "#{sdk_information}/0.18.0"
|
2254
2856
|
add_user_agent_information(sdk_information)
|
2255
2857
|
end
|
2256
2858
|
end
|