azure_cognitiveservices_face 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/1.0/generated/azure_cognitiveservices_face.rb +38 -22
- data/lib/1.0/generated/azure_cognitiveservices_face/face.rb +554 -77
- data/lib/1.0/generated/azure_cognitiveservices_face/face_client.rb +24 -5
- data/lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb +169 -36
- data/lib/1.0/generated/azure_cognitiveservices_face/large_face_list_operations.rb +1559 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/large_person_group_operations.rb +854 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb +1151 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/apply_snapshot_request.rb +69 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/detected_face.rb +13 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/face_attributes.rb +1 -1
- data/lib/1.0/generated/azure_cognitiveservices_face/models/face_list.rb +10 -1
- data/lib/1.0/generated/azure_cognitiveservices_face/models/find_similar_request.rb +23 -1
- data/lib/1.0/generated/azure_cognitiveservices_face/models/gender.rb +0 -1
- data/lib/1.0/generated/azure_cognitiveservices_face/models/identify_request.rb +34 -16
- data/lib/1.0/generated/azure_cognitiveservices_face/models/large_face_list.rb +81 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/large_person_group.rb +81 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/meta_data_contract.rb +72 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/name_and_user_data_contract.rb +1 -1
- data/lib/1.0/generated/azure_cognitiveservices_face/models/operation_status.rb +112 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/operation_status_type.rb +18 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/person_group.rb +11 -2
- data/lib/1.0/generated/azure_cognitiveservices_face/models/recognition_model.rb +16 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/snapshot.rb +136 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/snapshot_apply_mode.rb +15 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/snapshot_object_type.rb +18 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/take_snapshot_request.rb +101 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/training_status.rb +25 -7
- data/lib/1.0/generated/azure_cognitiveservices_face/models/{update_person_face_request.rb → update_face_request.rb} +5 -5
- data/lib/1.0/generated/azure_cognitiveservices_face/models/update_snapshot_request.rb +73 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_face_to_face_request.rb +1 -1
- data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_face_to_person_request.rb +27 -7
- data/lib/1.0/generated/azure_cognitiveservices_face/person_group_operations.rb +203 -34
- data/lib/1.0/generated/azure_cognitiveservices_face/person_group_person.rb +49 -29
- data/lib/1.0/generated/azure_cognitiveservices_face/snapshot_operations.rb +969 -0
- data/lib/profiles/latest/modules/face_profile_module.rb +125 -69
- data/lib/version.rb +1 -1
- metadata +19 -3
@@ -0,0 +1,1559 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::Face::V1_0
|
7
|
+
#
|
8
|
+
# An API for face detection, verification, and identification.
|
9
|
+
#
|
10
|
+
class LargeFaceListOperations
|
11
|
+
include MsRestAzure
|
12
|
+
|
13
|
+
#
|
14
|
+
# Creates and initializes a new instance of the LargeFaceListOperations class.
|
15
|
+
# @param client service class for accessing basic functionality.
|
16
|
+
#
|
17
|
+
def initialize(client)
|
18
|
+
@client = client
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [FaceClient] reference to the FaceClient
|
22
|
+
attr_reader :client
|
23
|
+
|
24
|
+
#
|
25
|
+
# Create an empty large face list with user-specified largeFaceListId, name, an
|
26
|
+
# optional userData and recognitionModel.
|
27
|
+
# <br /> Large face list is a list of faces, up to 1,000,000 faces, and used by
|
28
|
+
# [Face - Find
|
29
|
+
# Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
|
30
|
+
# <br /> After creation, user should use [LargeFaceList Face -
|
31
|
+
# Add](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3)
|
32
|
+
# to import the faces and [LargeFaceList -
|
33
|
+
# Train](/docs/services/563879b61984550e40cbbe8d/operations/5a158422d2de3616c086f2d1)
|
34
|
+
# to make it ready for [Face -
|
35
|
+
# FindSimilar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
|
36
|
+
# Faces are stored on server until [LargeFaceList -
|
37
|
+
# Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
|
38
|
+
# is called.
|
39
|
+
# <br /> Find Similar is used for scenario like finding celebrity-like faces,
|
40
|
+
# similar face filtering, or as a light way face identification. But if the
|
41
|
+
# actual use is to identify person, please use
|
42
|
+
# [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244)
|
43
|
+
# /
|
44
|
+
# [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d)
|
45
|
+
# and [Face -
|
46
|
+
# Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239).
|
47
|
+
# <br />
|
48
|
+
# * Free-tier subscription quota: 64 large face lists.
|
49
|
+
# * S0-tier subscription quota: 1,000,000 large face lists.
|
50
|
+
# <br />
|
51
|
+
# 'recognitionModel' should be specified to associate with this large face
|
52
|
+
# list. The default value for 'recognitionModel' is 'recognition_01', if the
|
53
|
+
# latest model needed, please explicitly specify the model you need in this
|
54
|
+
# parameter. New faces that are added to an existing large face list will use
|
55
|
+
# the recognition model that's already associated with the collection. Existing
|
56
|
+
# face features in a large face list can't be updated to features extracted by
|
57
|
+
# another version of recognition model.
|
58
|
+
#
|
59
|
+
#
|
60
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
61
|
+
# list.
|
62
|
+
# @param name [String] User defined name, maximum length is 128.
|
63
|
+
# @param user_data [String] User specified data. Length should not exceed 16KB.
|
64
|
+
# @param recognition_model [RecognitionModel] Possible values include:
|
65
|
+
# 'recognition_01', 'recognition_02'
|
66
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
67
|
+
# will be added to the HTTP request.
|
68
|
+
#
|
69
|
+
#
|
70
|
+
def create(large_face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
|
71
|
+
response = create_async(large_face_list_id, name:name, user_data:user_data, recognition_model:recognition_model, custom_headers:custom_headers).value!
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Create an empty large face list with user-specified largeFaceListId, name, an
|
77
|
+
# optional userData and recognitionModel.
|
78
|
+
# <br /> Large face list is a list of faces, up to 1,000,000 faces, and used by
|
79
|
+
# [Face - Find
|
80
|
+
# Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
|
81
|
+
# <br /> After creation, user should use [LargeFaceList Face -
|
82
|
+
# Add](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3)
|
83
|
+
# to import the faces and [LargeFaceList -
|
84
|
+
# Train](/docs/services/563879b61984550e40cbbe8d/operations/5a158422d2de3616c086f2d1)
|
85
|
+
# to make it ready for [Face -
|
86
|
+
# FindSimilar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
|
87
|
+
# Faces are stored on server until [LargeFaceList -
|
88
|
+
# Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
|
89
|
+
# is called.
|
90
|
+
# <br /> Find Similar is used for scenario like finding celebrity-like faces,
|
91
|
+
# similar face filtering, or as a light way face identification. But if the
|
92
|
+
# actual use is to identify person, please use
|
93
|
+
# [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244)
|
94
|
+
# /
|
95
|
+
# [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d)
|
96
|
+
# and [Face -
|
97
|
+
# Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239).
|
98
|
+
# <br />
|
99
|
+
# * Free-tier subscription quota: 64 large face lists.
|
100
|
+
# * S0-tier subscription quota: 1,000,000 large face lists.
|
101
|
+
# <br />
|
102
|
+
# 'recognitionModel' should be specified to associate with this large face
|
103
|
+
# list. The default value for 'recognitionModel' is 'recognition_01', if the
|
104
|
+
# latest model needed, please explicitly specify the model you need in this
|
105
|
+
# parameter. New faces that are added to an existing large face list will use
|
106
|
+
# the recognition model that's already associated with the collection. Existing
|
107
|
+
# face features in a large face list can't be updated to features extracted by
|
108
|
+
# another version of recognition model.
|
109
|
+
#
|
110
|
+
#
|
111
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
112
|
+
# list.
|
113
|
+
# @param name [String] User defined name, maximum length is 128.
|
114
|
+
# @param user_data [String] User specified data. Length should not exceed 16KB.
|
115
|
+
# @param recognition_model [RecognitionModel] Possible values include:
|
116
|
+
# 'recognition_01', 'recognition_02'
|
117
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
118
|
+
# will be added to the HTTP request.
|
119
|
+
#
|
120
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
121
|
+
#
|
122
|
+
def create_with_http_info(large_face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
|
123
|
+
create_async(large_face_list_id, name:name, user_data:user_data, recognition_model:recognition_model, custom_headers:custom_headers).value!
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# Create an empty large face list with user-specified largeFaceListId, name, an
|
128
|
+
# optional userData and recognitionModel.
|
129
|
+
# <br /> Large face list is a list of faces, up to 1,000,000 faces, and used by
|
130
|
+
# [Face - Find
|
131
|
+
# Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
|
132
|
+
# <br /> After creation, user should use [LargeFaceList Face -
|
133
|
+
# Add](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3)
|
134
|
+
# to import the faces and [LargeFaceList -
|
135
|
+
# Train](/docs/services/563879b61984550e40cbbe8d/operations/5a158422d2de3616c086f2d1)
|
136
|
+
# to make it ready for [Face -
|
137
|
+
# FindSimilar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
|
138
|
+
# Faces are stored on server until [LargeFaceList -
|
139
|
+
# Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
|
140
|
+
# is called.
|
141
|
+
# <br /> Find Similar is used for scenario like finding celebrity-like faces,
|
142
|
+
# similar face filtering, or as a light way face identification. But if the
|
143
|
+
# actual use is to identify person, please use
|
144
|
+
# [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244)
|
145
|
+
# /
|
146
|
+
# [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d)
|
147
|
+
# and [Face -
|
148
|
+
# Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239).
|
149
|
+
# <br />
|
150
|
+
# * Free-tier subscription quota: 64 large face lists.
|
151
|
+
# * S0-tier subscription quota: 1,000,000 large face lists.
|
152
|
+
# <br />
|
153
|
+
# 'recognitionModel' should be specified to associate with this large face
|
154
|
+
# list. The default value for 'recognitionModel' is 'recognition_01', if the
|
155
|
+
# latest model needed, please explicitly specify the model you need in this
|
156
|
+
# parameter. New faces that are added to an existing large face list will use
|
157
|
+
# the recognition model that's already associated with the collection. Existing
|
158
|
+
# face features in a large face list can't be updated to features extracted by
|
159
|
+
# another version of recognition model.
|
160
|
+
#
|
161
|
+
#
|
162
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
163
|
+
# list.
|
164
|
+
# @param name [String] User defined name, maximum length is 128.
|
165
|
+
# @param user_data [String] User specified data. Length should not exceed 16KB.
|
166
|
+
# @param recognition_model [RecognitionModel] Possible values include:
|
167
|
+
# 'recognition_01', 'recognition_02'
|
168
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
169
|
+
# to the HTTP request.
|
170
|
+
#
|
171
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
172
|
+
#
|
173
|
+
def create_async(large_face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
|
174
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
175
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
176
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
177
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
178
|
+
fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
|
179
|
+
fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384
|
180
|
+
|
181
|
+
body = MetaDataContract.new
|
182
|
+
unless name.nil? && user_data.nil? && recognition_model.nil?
|
183
|
+
body.name = name
|
184
|
+
body.user_data = user_data
|
185
|
+
body.recognition_model = recognition_model
|
186
|
+
end
|
187
|
+
|
188
|
+
request_headers = {}
|
189
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
190
|
+
|
191
|
+
# Set Headers
|
192
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
193
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
194
|
+
|
195
|
+
# Serialize Request
|
196
|
+
request_mapper = Azure::CognitiveServices::Face::V1_0::Models::MetaDataContract.mapper()
|
197
|
+
request_content = @client.serialize(request_mapper, body)
|
198
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
199
|
+
|
200
|
+
path_template = 'largefacelists/{largeFaceListId}'
|
201
|
+
|
202
|
+
request_url = @base_url || @client.base_url
|
203
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
204
|
+
|
205
|
+
options = {
|
206
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
207
|
+
path_params: {'largeFaceListId' => large_face_list_id},
|
208
|
+
body: request_content,
|
209
|
+
headers: request_headers.merge(custom_headers || {}),
|
210
|
+
base_url: request_url
|
211
|
+
}
|
212
|
+
promise = @client.make_request_async(:put, path_template, options)
|
213
|
+
|
214
|
+
promise = promise.then do |result|
|
215
|
+
http_response = result.response
|
216
|
+
status_code = http_response.status
|
217
|
+
response_content = http_response.body
|
218
|
+
unless status_code == 200
|
219
|
+
error_model = JSON.load(response_content)
|
220
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
221
|
+
end
|
222
|
+
|
223
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
224
|
+
|
225
|
+
result
|
226
|
+
end
|
227
|
+
|
228
|
+
promise.execute
|
229
|
+
end
|
230
|
+
|
231
|
+
#
|
232
|
+
# Retrieve a large face list’s largeFaceListId, name, userData and
|
233
|
+
# recognitionModel.
|
234
|
+
#
|
235
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
236
|
+
# list.
|
237
|
+
# @param return_recognition_model [Boolean] A value indicating whether the
|
238
|
+
# operation should return 'recognitionModel' in response.
|
239
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
240
|
+
# will be added to the HTTP request.
|
241
|
+
#
|
242
|
+
# @return [LargeFaceList] operation results.
|
243
|
+
#
|
244
|
+
def get(large_face_list_id, return_recognition_model:false, custom_headers:nil)
|
245
|
+
response = get_async(large_face_list_id, return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
|
246
|
+
response.body unless response.nil?
|
247
|
+
end
|
248
|
+
|
249
|
+
#
|
250
|
+
# Retrieve a large face list’s largeFaceListId, name, userData and
|
251
|
+
# recognitionModel.
|
252
|
+
#
|
253
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
254
|
+
# list.
|
255
|
+
# @param return_recognition_model [Boolean] A value indicating whether the
|
256
|
+
# operation should return 'recognitionModel' in response.
|
257
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
258
|
+
# will be added to the HTTP request.
|
259
|
+
#
|
260
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
261
|
+
#
|
262
|
+
def get_with_http_info(large_face_list_id, return_recognition_model:false, custom_headers:nil)
|
263
|
+
get_async(large_face_list_id, return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
|
264
|
+
end
|
265
|
+
|
266
|
+
#
|
267
|
+
# Retrieve a large face list’s largeFaceListId, name, userData and
|
268
|
+
# recognitionModel.
|
269
|
+
#
|
270
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
271
|
+
# list.
|
272
|
+
# @param return_recognition_model [Boolean] A value indicating whether the
|
273
|
+
# operation should return 'recognitionModel' in response.
|
274
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
275
|
+
# to the HTTP request.
|
276
|
+
#
|
277
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
278
|
+
#
|
279
|
+
def get_async(large_face_list_id, return_recognition_model:false, custom_headers:nil)
|
280
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
281
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
282
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
283
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
284
|
+
|
285
|
+
|
286
|
+
request_headers = {}
|
287
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
288
|
+
|
289
|
+
# Set Headers
|
290
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
291
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
292
|
+
path_template = 'largefacelists/{largeFaceListId}'
|
293
|
+
|
294
|
+
request_url = @base_url || @client.base_url
|
295
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
296
|
+
|
297
|
+
options = {
|
298
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
299
|
+
path_params: {'largeFaceListId' => large_face_list_id},
|
300
|
+
query_params: {'returnRecognitionModel' => return_recognition_model},
|
301
|
+
headers: request_headers.merge(custom_headers || {}),
|
302
|
+
base_url: request_url
|
303
|
+
}
|
304
|
+
promise = @client.make_request_async(:get, path_template, options)
|
305
|
+
|
306
|
+
promise = promise.then do |result|
|
307
|
+
http_response = result.response
|
308
|
+
status_code = http_response.status
|
309
|
+
response_content = http_response.body
|
310
|
+
unless status_code == 200
|
311
|
+
error_model = JSON.load(response_content)
|
312
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
313
|
+
end
|
314
|
+
|
315
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
316
|
+
# Deserialize Response
|
317
|
+
if status_code == 200
|
318
|
+
begin
|
319
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
320
|
+
result_mapper = Azure::CognitiveServices::Face::V1_0::Models::LargeFaceList.mapper()
|
321
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
322
|
+
rescue Exception => e
|
323
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
result
|
328
|
+
end
|
329
|
+
|
330
|
+
promise.execute
|
331
|
+
end
|
332
|
+
|
333
|
+
#
|
334
|
+
# Update information of a large face list.
|
335
|
+
#
|
336
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
337
|
+
# list.
|
338
|
+
# @param name [String] User defined name, maximum length is 128.
|
339
|
+
# @param user_data [String] User specified data. Length should not exceed 16KB.
|
340
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
341
|
+
# will be added to the HTTP request.
|
342
|
+
#
|
343
|
+
#
|
344
|
+
def update(large_face_list_id, name:nil, user_data:nil, custom_headers:nil)
|
345
|
+
response = update_async(large_face_list_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
|
346
|
+
nil
|
347
|
+
end
|
348
|
+
|
349
|
+
#
|
350
|
+
# Update information of a large face list.
|
351
|
+
#
|
352
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
353
|
+
# list.
|
354
|
+
# @param name [String] User defined name, maximum length is 128.
|
355
|
+
# @param user_data [String] User specified data. Length should not exceed 16KB.
|
356
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
357
|
+
# will be added to the HTTP request.
|
358
|
+
#
|
359
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
360
|
+
#
|
361
|
+
def update_with_http_info(large_face_list_id, name:nil, user_data:nil, custom_headers:nil)
|
362
|
+
update_async(large_face_list_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
|
363
|
+
end
|
364
|
+
|
365
|
+
#
|
366
|
+
# Update information of a large face list.
|
367
|
+
#
|
368
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
369
|
+
# list.
|
370
|
+
# @param name [String] User defined name, maximum length is 128.
|
371
|
+
# @param user_data [String] User specified data. Length should not exceed 16KB.
|
372
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
373
|
+
# to the HTTP request.
|
374
|
+
#
|
375
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
376
|
+
#
|
377
|
+
def update_async(large_face_list_id, name:nil, user_data:nil, custom_headers:nil)
|
378
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
379
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
380
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
381
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
382
|
+
fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
|
383
|
+
fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384
|
384
|
+
|
385
|
+
body = NameAndUserDataContract.new
|
386
|
+
unless name.nil? && user_data.nil?
|
387
|
+
body.name = name
|
388
|
+
body.user_data = user_data
|
389
|
+
end
|
390
|
+
|
391
|
+
request_headers = {}
|
392
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
393
|
+
|
394
|
+
# Set Headers
|
395
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
396
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
397
|
+
|
398
|
+
# Serialize Request
|
399
|
+
request_mapper = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.mapper()
|
400
|
+
request_content = @client.serialize(request_mapper, body)
|
401
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
402
|
+
|
403
|
+
path_template = 'largefacelists/{largeFaceListId}'
|
404
|
+
|
405
|
+
request_url = @base_url || @client.base_url
|
406
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
407
|
+
|
408
|
+
options = {
|
409
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
410
|
+
path_params: {'largeFaceListId' => large_face_list_id},
|
411
|
+
body: request_content,
|
412
|
+
headers: request_headers.merge(custom_headers || {}),
|
413
|
+
base_url: request_url
|
414
|
+
}
|
415
|
+
promise = @client.make_request_async(:patch, path_template, options)
|
416
|
+
|
417
|
+
promise = promise.then do |result|
|
418
|
+
http_response = result.response
|
419
|
+
status_code = http_response.status
|
420
|
+
response_content = http_response.body
|
421
|
+
unless status_code == 200
|
422
|
+
error_model = JSON.load(response_content)
|
423
|
+
fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
|
424
|
+
end
|
425
|
+
|
426
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
427
|
+
|
428
|
+
result
|
429
|
+
end
|
430
|
+
|
431
|
+
promise.execute
|
432
|
+
end
|
433
|
+
|
434
|
+
#
|
435
|
+
# Delete an existing large face list according to faceListId. Persisted face
|
436
|
+
# images in the large face list will also be deleted.
|
437
|
+
#
|
438
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
439
|
+
# list.
|
440
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
441
|
+
# will be added to the HTTP request.
|
442
|
+
#
|
443
|
+
#
|
444
|
+
def delete(large_face_list_id, custom_headers:nil)
|
445
|
+
response = delete_async(large_face_list_id, custom_headers:custom_headers).value!
|
446
|
+
nil
|
447
|
+
end
|
448
|
+
|
449
|
+
#
|
450
|
+
# Delete an existing large face list according to faceListId. Persisted face
|
451
|
+
# images in the large face list will also be deleted.
|
452
|
+
#
|
453
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
454
|
+
# list.
|
455
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
456
|
+
# will be added to the HTTP request.
|
457
|
+
#
|
458
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
459
|
+
#
|
460
|
+
def delete_with_http_info(large_face_list_id, custom_headers:nil)
|
461
|
+
delete_async(large_face_list_id, custom_headers:custom_headers).value!
|
462
|
+
end
|
463
|
+
|
464
|
+
#
|
465
|
+
# Delete an existing large face list according to faceListId. Persisted face
|
466
|
+
# images in the large face list will also be deleted.
|
467
|
+
#
|
468
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
469
|
+
# list.
|
470
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
471
|
+
# to the HTTP request.
|
472
|
+
#
|
473
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
474
|
+
#
|
475
|
+
def delete_async(large_face_list_id, custom_headers:nil)
|
476
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
477
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
478
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
479
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
480
|
+
|
481
|
+
|
482
|
+
request_headers = {}
|
483
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
484
|
+
|
485
|
+
# Set Headers
|
486
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
487
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
488
|
+
path_template = 'largefacelists/{largeFaceListId}'
|
489
|
+
|
490
|
+
request_url = @base_url || @client.base_url
|
491
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
492
|
+
|
493
|
+
options = {
|
494
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
495
|
+
path_params: {'largeFaceListId' => large_face_list_id},
|
496
|
+
headers: request_headers.merge(custom_headers || {}),
|
497
|
+
base_url: request_url
|
498
|
+
}
|
499
|
+
promise = @client.make_request_async(:delete, path_template, options)
|
500
|
+
|
501
|
+
promise = promise.then do |result|
|
502
|
+
http_response = result.response
|
503
|
+
status_code = http_response.status
|
504
|
+
response_content = http_response.body
|
505
|
+
unless status_code == 200
|
506
|
+
error_model = JSON.load(response_content)
|
507
|
+
fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
|
508
|
+
end
|
509
|
+
|
510
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
511
|
+
|
512
|
+
result
|
513
|
+
end
|
514
|
+
|
515
|
+
promise.execute
|
516
|
+
end
|
517
|
+
|
518
|
+
#
|
519
|
+
# Retrieve the training status of a large face list (completed or ongoing).
|
520
|
+
#
|
521
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
522
|
+
# list.
|
523
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
524
|
+
# will be added to the HTTP request.
|
525
|
+
#
|
526
|
+
# @return [TrainingStatus] operation results.
|
527
|
+
#
|
528
|
+
def get_training_status(large_face_list_id, custom_headers:nil)
|
529
|
+
response = get_training_status_async(large_face_list_id, custom_headers:custom_headers).value!
|
530
|
+
response.body unless response.nil?
|
531
|
+
end
|
532
|
+
|
533
|
+
#
|
534
|
+
# Retrieve the training status of a large face list (completed or ongoing).
|
535
|
+
#
|
536
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
537
|
+
# list.
|
538
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
539
|
+
# will be added to the HTTP request.
|
540
|
+
#
|
541
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
542
|
+
#
|
543
|
+
def get_training_status_with_http_info(large_face_list_id, custom_headers:nil)
|
544
|
+
get_training_status_async(large_face_list_id, custom_headers:custom_headers).value!
|
545
|
+
end
|
546
|
+
|
547
|
+
#
|
548
|
+
# Retrieve the training status of a large face list (completed or ongoing).
|
549
|
+
#
|
550
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
551
|
+
# list.
|
552
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
553
|
+
# to the HTTP request.
|
554
|
+
#
|
555
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
556
|
+
#
|
557
|
+
def get_training_status_async(large_face_list_id, custom_headers:nil)
|
558
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
559
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
560
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
561
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
562
|
+
|
563
|
+
|
564
|
+
request_headers = {}
|
565
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
566
|
+
|
567
|
+
# Set Headers
|
568
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
569
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
570
|
+
path_template = 'largefacelists/{largeFaceListId}/training'
|
571
|
+
|
572
|
+
request_url = @base_url || @client.base_url
|
573
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
574
|
+
|
575
|
+
options = {
|
576
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
577
|
+
path_params: {'largeFaceListId' => large_face_list_id},
|
578
|
+
headers: request_headers.merge(custom_headers || {}),
|
579
|
+
base_url: request_url
|
580
|
+
}
|
581
|
+
promise = @client.make_request_async(:get, path_template, options)
|
582
|
+
|
583
|
+
promise = promise.then do |result|
|
584
|
+
http_response = result.response
|
585
|
+
status_code = http_response.status
|
586
|
+
response_content = http_response.body
|
587
|
+
unless status_code == 200
|
588
|
+
error_model = JSON.load(response_content)
|
589
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
590
|
+
end
|
591
|
+
|
592
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
593
|
+
# Deserialize Response
|
594
|
+
if status_code == 200
|
595
|
+
begin
|
596
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
597
|
+
result_mapper = Azure::CognitiveServices::Face::V1_0::Models::TrainingStatus.mapper()
|
598
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
599
|
+
rescue Exception => e
|
600
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
601
|
+
end
|
602
|
+
end
|
603
|
+
|
604
|
+
result
|
605
|
+
end
|
606
|
+
|
607
|
+
promise.execute
|
608
|
+
end
|
609
|
+
|
610
|
+
#
|
611
|
+
# List large face lists’ information of largeFaceListId, name, userData and
|
612
|
+
# recognitionModel. <br />
|
613
|
+
# To get face information inside largeFaceList use [LargeFaceList Face -
|
614
|
+
# Get](/docs/services/563879b61984550e40cbbe8d/operations/5a158cf2d2de3616c086f2d5)<br
|
615
|
+
# />
|
616
|
+
# * Large face lists are stored in alphabetical order of largeFaceListId.
|
617
|
+
# * "start" parameter (string, optional) is a user-provided largeFaceListId
|
618
|
+
# value that returned entries have larger ids by string comparison. "start" set
|
619
|
+
# to empty to indicate return from the first item.
|
620
|
+
# * "top" parameter (int, optional) specifies the number of entries to return.
|
621
|
+
# A maximal of 1000 entries can be returned in one call. To fetch more, you can
|
622
|
+
# specify "start" with the last returned entry’s Id of the current call.
|
623
|
+
# <br />
|
624
|
+
# For example, total 5 large person lists: "list1", ..., "list5".
|
625
|
+
# <br /> "start=&top=" will return all 5 lists.
|
626
|
+
# <br /> "start=&top=2" will return "list1", "list2".
|
627
|
+
# <br /> "start=list2&top=3" will return "list3", "list4", "list5".
|
628
|
+
#
|
629
|
+
#
|
630
|
+
# @param return_recognition_model [Boolean] A value indicating whether the
|
631
|
+
# operation should return 'recognitionModel' in response.
|
632
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
633
|
+
# will be added to the HTTP request.
|
634
|
+
#
|
635
|
+
# @return [Array] operation results.
|
636
|
+
#
|
637
|
+
def list(return_recognition_model:false, custom_headers:nil)
|
638
|
+
response = list_async(return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
|
639
|
+
response.body unless response.nil?
|
640
|
+
end
|
641
|
+
|
642
|
+
#
|
643
|
+
# List large face lists’ information of largeFaceListId, name, userData and
|
644
|
+
# recognitionModel. <br />
|
645
|
+
# To get face information inside largeFaceList use [LargeFaceList Face -
|
646
|
+
# Get](/docs/services/563879b61984550e40cbbe8d/operations/5a158cf2d2de3616c086f2d5)<br
|
647
|
+
# />
|
648
|
+
# * Large face lists are stored in alphabetical order of largeFaceListId.
|
649
|
+
# * "start" parameter (string, optional) is a user-provided largeFaceListId
|
650
|
+
# value that returned entries have larger ids by string comparison. "start" set
|
651
|
+
# to empty to indicate return from the first item.
|
652
|
+
# * "top" parameter (int, optional) specifies the number of entries to return.
|
653
|
+
# A maximal of 1000 entries can be returned in one call. To fetch more, you can
|
654
|
+
# specify "start" with the last returned entry’s Id of the current call.
|
655
|
+
# <br />
|
656
|
+
# For example, total 5 large person lists: "list1", ..., "list5".
|
657
|
+
# <br /> "start=&top=" will return all 5 lists.
|
658
|
+
# <br /> "start=&top=2" will return "list1", "list2".
|
659
|
+
# <br /> "start=list2&top=3" will return "list3", "list4", "list5".
|
660
|
+
#
|
661
|
+
#
|
662
|
+
# @param return_recognition_model [Boolean] A value indicating whether the
|
663
|
+
# operation should return 'recognitionModel' in response.
|
664
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
665
|
+
# will be added to the HTTP request.
|
666
|
+
#
|
667
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
668
|
+
#
|
669
|
+
def list_with_http_info(return_recognition_model:false, custom_headers:nil)
|
670
|
+
list_async(return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
|
671
|
+
end
|
672
|
+
|
673
|
+
#
|
674
|
+
# List large face lists’ information of largeFaceListId, name, userData and
|
675
|
+
# recognitionModel. <br />
|
676
|
+
# To get face information inside largeFaceList use [LargeFaceList Face -
|
677
|
+
# Get](/docs/services/563879b61984550e40cbbe8d/operations/5a158cf2d2de3616c086f2d5)<br
|
678
|
+
# />
|
679
|
+
# * Large face lists are stored in alphabetical order of largeFaceListId.
|
680
|
+
# * "start" parameter (string, optional) is a user-provided largeFaceListId
|
681
|
+
# value that returned entries have larger ids by string comparison. "start" set
|
682
|
+
# to empty to indicate return from the first item.
|
683
|
+
# * "top" parameter (int, optional) specifies the number of entries to return.
|
684
|
+
# A maximal of 1000 entries can be returned in one call. To fetch more, you can
|
685
|
+
# specify "start" with the last returned entry’s Id of the current call.
|
686
|
+
# <br />
|
687
|
+
# For example, total 5 large person lists: "list1", ..., "list5".
|
688
|
+
# <br /> "start=&top=" will return all 5 lists.
|
689
|
+
# <br /> "start=&top=2" will return "list1", "list2".
|
690
|
+
# <br /> "start=list2&top=3" will return "list3", "list4", "list5".
|
691
|
+
#
|
692
|
+
#
|
693
|
+
# @param return_recognition_model [Boolean] A value indicating whether the
|
694
|
+
# operation should return 'recognitionModel' in response.
|
695
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
696
|
+
# to the HTTP request.
|
697
|
+
#
|
698
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
699
|
+
#
|
700
|
+
def list_async(return_recognition_model:false, custom_headers:nil)
|
701
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
702
|
+
|
703
|
+
|
704
|
+
request_headers = {}
|
705
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
706
|
+
|
707
|
+
# Set Headers
|
708
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
709
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
710
|
+
path_template = 'largefacelists'
|
711
|
+
|
712
|
+
request_url = @base_url || @client.base_url
|
713
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
714
|
+
|
715
|
+
options = {
|
716
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
717
|
+
query_params: {'returnRecognitionModel' => return_recognition_model},
|
718
|
+
headers: request_headers.merge(custom_headers || {}),
|
719
|
+
base_url: request_url
|
720
|
+
}
|
721
|
+
promise = @client.make_request_async(:get, path_template, options)
|
722
|
+
|
723
|
+
promise = promise.then do |result|
|
724
|
+
http_response = result.response
|
725
|
+
status_code = http_response.status
|
726
|
+
response_content = http_response.body
|
727
|
+
unless status_code == 200
|
728
|
+
error_model = JSON.load(response_content)
|
729
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
730
|
+
end
|
731
|
+
|
732
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
733
|
+
# Deserialize Response
|
734
|
+
if status_code == 200
|
735
|
+
begin
|
736
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
737
|
+
result_mapper = {
|
738
|
+
client_side_validation: true,
|
739
|
+
required: false,
|
740
|
+
serialized_name: 'parsed_response',
|
741
|
+
type: {
|
742
|
+
name: 'Sequence',
|
743
|
+
element: {
|
744
|
+
client_side_validation: true,
|
745
|
+
required: false,
|
746
|
+
serialized_name: 'LargeFaceListElementType',
|
747
|
+
type: {
|
748
|
+
name: 'Composite',
|
749
|
+
class_name: 'LargeFaceList'
|
750
|
+
}
|
751
|
+
}
|
752
|
+
}
|
753
|
+
}
|
754
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
755
|
+
rescue Exception => e
|
756
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
757
|
+
end
|
758
|
+
end
|
759
|
+
|
760
|
+
result
|
761
|
+
end
|
762
|
+
|
763
|
+
promise.execute
|
764
|
+
end
|
765
|
+
|
766
|
+
#
|
767
|
+
# Queue a large face list training task, the training task may not be started
|
768
|
+
# immediately.
|
769
|
+
#
|
770
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
771
|
+
# list.
|
772
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
773
|
+
# will be added to the HTTP request.
|
774
|
+
#
|
775
|
+
#
|
776
|
+
def train(large_face_list_id, custom_headers:nil)
|
777
|
+
response = train_async(large_face_list_id, custom_headers:custom_headers).value!
|
778
|
+
nil
|
779
|
+
end
|
780
|
+
|
781
|
+
#
|
782
|
+
# Queue a large face list training task, the training task may not be started
|
783
|
+
# immediately.
|
784
|
+
#
|
785
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
786
|
+
# list.
|
787
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
788
|
+
# will be added to the HTTP request.
|
789
|
+
#
|
790
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
791
|
+
#
|
792
|
+
def train_with_http_info(large_face_list_id, custom_headers:nil)
|
793
|
+
train_async(large_face_list_id, custom_headers:custom_headers).value!
|
794
|
+
end
|
795
|
+
|
796
|
+
#
|
797
|
+
# Queue a large face list training task, the training task may not be started
|
798
|
+
# immediately.
|
799
|
+
#
|
800
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
801
|
+
# list.
|
802
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
803
|
+
# to the HTTP request.
|
804
|
+
#
|
805
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
806
|
+
#
|
807
|
+
def train_async(large_face_list_id, custom_headers:nil)
|
808
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
809
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
810
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
811
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
812
|
+
|
813
|
+
|
814
|
+
request_headers = {}
|
815
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
816
|
+
|
817
|
+
# Set Headers
|
818
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
819
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
820
|
+
path_template = 'largefacelists/{largeFaceListId}/train'
|
821
|
+
|
822
|
+
request_url = @base_url || @client.base_url
|
823
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
824
|
+
|
825
|
+
options = {
|
826
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
827
|
+
path_params: {'largeFaceListId' => large_face_list_id},
|
828
|
+
headers: request_headers.merge(custom_headers || {}),
|
829
|
+
base_url: request_url
|
830
|
+
}
|
831
|
+
promise = @client.make_request_async(:post, path_template, options)
|
832
|
+
|
833
|
+
promise = promise.then do |result|
|
834
|
+
http_response = result.response
|
835
|
+
status_code = http_response.status
|
836
|
+
response_content = http_response.body
|
837
|
+
unless status_code == 202
|
838
|
+
error_model = JSON.load(response_content)
|
839
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
840
|
+
end
|
841
|
+
|
842
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
843
|
+
|
844
|
+
result
|
845
|
+
end
|
846
|
+
|
847
|
+
promise.execute
|
848
|
+
end
|
849
|
+
|
850
|
+
#
|
851
|
+
# Delete an existing face from a large face list (given by a persistedFaceId
|
852
|
+
# and a largeFaceListId). Persisted image related to the face will also be
|
853
|
+
# deleted.
|
854
|
+
#
|
855
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
856
|
+
# list.
|
857
|
+
# @param persisted_face_id Id referencing a particular persistedFaceId of an
|
858
|
+
# existing face.
|
859
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
860
|
+
# will be added to the HTTP request.
|
861
|
+
#
|
862
|
+
#
|
863
|
+
def delete_face(large_face_list_id, persisted_face_id, custom_headers:nil)
|
864
|
+
response = delete_face_async(large_face_list_id, persisted_face_id, custom_headers:custom_headers).value!
|
865
|
+
nil
|
866
|
+
end
|
867
|
+
|
868
|
+
#
|
869
|
+
# Delete an existing face from a large face list (given by a persistedFaceId
|
870
|
+
# and a largeFaceListId). Persisted image related to the face will also be
|
871
|
+
# deleted.
|
872
|
+
#
|
873
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
874
|
+
# list.
|
875
|
+
# @param persisted_face_id Id referencing a particular persistedFaceId of an
|
876
|
+
# existing face.
|
877
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
878
|
+
# will be added to the HTTP request.
|
879
|
+
#
|
880
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
881
|
+
#
|
882
|
+
def delete_face_with_http_info(large_face_list_id, persisted_face_id, custom_headers:nil)
|
883
|
+
delete_face_async(large_face_list_id, persisted_face_id, custom_headers:custom_headers).value!
|
884
|
+
end
|
885
|
+
|
886
|
+
#
|
887
|
+
# Delete an existing face from a large face list (given by a persistedFaceId
|
888
|
+
# and a largeFaceListId). Persisted image related to the face will also be
|
889
|
+
# deleted.
|
890
|
+
#
|
891
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
892
|
+
# list.
|
893
|
+
# @param persisted_face_id Id referencing a particular persistedFaceId of an
|
894
|
+
# existing face.
|
895
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
896
|
+
# to the HTTP request.
|
897
|
+
#
|
898
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
899
|
+
#
|
900
|
+
def delete_face_async(large_face_list_id, persisted_face_id, custom_headers:nil)
|
901
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
902
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
903
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
904
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
905
|
+
fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
|
906
|
+
|
907
|
+
|
908
|
+
request_headers = {}
|
909
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
910
|
+
|
911
|
+
# Set Headers
|
912
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
913
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
914
|
+
path_template = 'largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'
|
915
|
+
|
916
|
+
request_url = @base_url || @client.base_url
|
917
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
918
|
+
|
919
|
+
options = {
|
920
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
921
|
+
path_params: {'largeFaceListId' => large_face_list_id,'persistedFaceId' => persisted_face_id},
|
922
|
+
headers: request_headers.merge(custom_headers || {}),
|
923
|
+
base_url: request_url
|
924
|
+
}
|
925
|
+
promise = @client.make_request_async(:delete, path_template, options)
|
926
|
+
|
927
|
+
promise = promise.then do |result|
|
928
|
+
http_response = result.response
|
929
|
+
status_code = http_response.status
|
930
|
+
response_content = http_response.body
|
931
|
+
unless status_code == 200
|
932
|
+
error_model = JSON.load(response_content)
|
933
|
+
fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
|
934
|
+
end
|
935
|
+
|
936
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
937
|
+
|
938
|
+
result
|
939
|
+
end
|
940
|
+
|
941
|
+
promise.execute
|
942
|
+
end
|
943
|
+
|
944
|
+
#
|
945
|
+
# Retrieve information about a persisted face (specified by persistedFaceId and
|
946
|
+
# its belonging largeFaceListId).
|
947
|
+
#
|
948
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
949
|
+
# list.
|
950
|
+
# @param persisted_face_id Id referencing a particular persistedFaceId of an
|
951
|
+
# existing face.
|
952
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
953
|
+
# will be added to the HTTP request.
|
954
|
+
#
|
955
|
+
# @return [PersistedFace] operation results.
|
956
|
+
#
|
957
|
+
def get_face(large_face_list_id, persisted_face_id, custom_headers:nil)
|
958
|
+
response = get_face_async(large_face_list_id, persisted_face_id, custom_headers:custom_headers).value!
|
959
|
+
response.body unless response.nil?
|
960
|
+
end
|
961
|
+
|
962
|
+
#
|
963
|
+
# Retrieve information about a persisted face (specified by persistedFaceId and
|
964
|
+
# its belonging largeFaceListId).
|
965
|
+
#
|
966
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
967
|
+
# list.
|
968
|
+
# @param persisted_face_id Id referencing a particular persistedFaceId of an
|
969
|
+
# existing face.
|
970
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
971
|
+
# will be added to the HTTP request.
|
972
|
+
#
|
973
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
974
|
+
#
|
975
|
+
def get_face_with_http_info(large_face_list_id, persisted_face_id, custom_headers:nil)
|
976
|
+
get_face_async(large_face_list_id, persisted_face_id, custom_headers:custom_headers).value!
|
977
|
+
end
|
978
|
+
|
979
|
+
#
|
980
|
+
# Retrieve information about a persisted face (specified by persistedFaceId and
|
981
|
+
# its belonging largeFaceListId).
|
982
|
+
#
|
983
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
984
|
+
# list.
|
985
|
+
# @param persisted_face_id Id referencing a particular persistedFaceId of an
|
986
|
+
# existing face.
|
987
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
988
|
+
# to the HTTP request.
|
989
|
+
#
|
990
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
991
|
+
#
|
992
|
+
def get_face_async(large_face_list_id, persisted_face_id, custom_headers:nil)
|
993
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
994
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
995
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
996
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
997
|
+
fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
|
998
|
+
|
999
|
+
|
1000
|
+
request_headers = {}
|
1001
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
1002
|
+
|
1003
|
+
# Set Headers
|
1004
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
1005
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
1006
|
+
path_template = 'largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'
|
1007
|
+
|
1008
|
+
request_url = @base_url || @client.base_url
|
1009
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
1010
|
+
|
1011
|
+
options = {
|
1012
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1013
|
+
path_params: {'largeFaceListId' => large_face_list_id,'persistedFaceId' => persisted_face_id},
|
1014
|
+
headers: request_headers.merge(custom_headers || {}),
|
1015
|
+
base_url: request_url
|
1016
|
+
}
|
1017
|
+
promise = @client.make_request_async(:get, path_template, options)
|
1018
|
+
|
1019
|
+
promise = promise.then do |result|
|
1020
|
+
http_response = result.response
|
1021
|
+
status_code = http_response.status
|
1022
|
+
response_content = http_response.body
|
1023
|
+
unless status_code == 200
|
1024
|
+
error_model = JSON.load(response_content)
|
1025
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
1029
|
+
# Deserialize Response
|
1030
|
+
if status_code == 200
|
1031
|
+
begin
|
1032
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
1033
|
+
result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
|
1034
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
1035
|
+
rescue Exception => e
|
1036
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
1037
|
+
end
|
1038
|
+
end
|
1039
|
+
|
1040
|
+
result
|
1041
|
+
end
|
1042
|
+
|
1043
|
+
promise.execute
|
1044
|
+
end
|
1045
|
+
|
1046
|
+
#
|
1047
|
+
# Update a persisted face's userData field.
|
1048
|
+
#
|
1049
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1050
|
+
# list.
|
1051
|
+
# @param persisted_face_id Id referencing a particular persistedFaceId of an
|
1052
|
+
# existing face.
|
1053
|
+
# @param user_data [String] User-provided data attached to the face. The size
|
1054
|
+
# limit is 1KB.
|
1055
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1056
|
+
# will be added to the HTTP request.
|
1057
|
+
#
|
1058
|
+
#
|
1059
|
+
def update_face(large_face_list_id, persisted_face_id, user_data:nil, custom_headers:nil)
|
1060
|
+
response = update_face_async(large_face_list_id, persisted_face_id, user_data:user_data, custom_headers:custom_headers).value!
|
1061
|
+
nil
|
1062
|
+
end
|
1063
|
+
|
1064
|
+
#
|
1065
|
+
# Update a persisted face's userData field.
|
1066
|
+
#
|
1067
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1068
|
+
# list.
|
1069
|
+
# @param persisted_face_id Id referencing a particular persistedFaceId of an
|
1070
|
+
# existing face.
|
1071
|
+
# @param user_data [String] User-provided data attached to the face. The size
|
1072
|
+
# limit is 1KB.
|
1073
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1074
|
+
# will be added to the HTTP request.
|
1075
|
+
#
|
1076
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
1077
|
+
#
|
1078
|
+
def update_face_with_http_info(large_face_list_id, persisted_face_id, user_data:nil, custom_headers:nil)
|
1079
|
+
update_face_async(large_face_list_id, persisted_face_id, user_data:user_data, custom_headers:custom_headers).value!
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
#
|
1083
|
+
# Update a persisted face's userData field.
|
1084
|
+
#
|
1085
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1086
|
+
# list.
|
1087
|
+
# @param persisted_face_id Id referencing a particular persistedFaceId of an
|
1088
|
+
# existing face.
|
1089
|
+
# @param user_data [String] User-provided data attached to the face. The size
|
1090
|
+
# limit is 1KB.
|
1091
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1092
|
+
# to the HTTP request.
|
1093
|
+
#
|
1094
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1095
|
+
#
|
1096
|
+
def update_face_async(large_face_list_id, persisted_face_id, user_data:nil, custom_headers:nil)
|
1097
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
1098
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
1099
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
1100
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
1101
|
+
fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
|
1102
|
+
fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
|
1103
|
+
|
1104
|
+
body = UpdateFaceRequest.new
|
1105
|
+
unless user_data.nil?
|
1106
|
+
body.user_data = user_data
|
1107
|
+
end
|
1108
|
+
|
1109
|
+
request_headers = {}
|
1110
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
1111
|
+
|
1112
|
+
# Set Headers
|
1113
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
1114
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
1115
|
+
|
1116
|
+
# Serialize Request
|
1117
|
+
request_mapper = Azure::CognitiveServices::Face::V1_0::Models::UpdateFaceRequest.mapper()
|
1118
|
+
request_content = @client.serialize(request_mapper, body)
|
1119
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
1120
|
+
|
1121
|
+
path_template = 'largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'
|
1122
|
+
|
1123
|
+
request_url = @base_url || @client.base_url
|
1124
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
1125
|
+
|
1126
|
+
options = {
|
1127
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1128
|
+
path_params: {'largeFaceListId' => large_face_list_id,'persistedFaceId' => persisted_face_id},
|
1129
|
+
body: request_content,
|
1130
|
+
headers: request_headers.merge(custom_headers || {}),
|
1131
|
+
base_url: request_url
|
1132
|
+
}
|
1133
|
+
promise = @client.make_request_async(:patch, path_template, options)
|
1134
|
+
|
1135
|
+
promise = promise.then do |result|
|
1136
|
+
http_response = result.response
|
1137
|
+
status_code = http_response.status
|
1138
|
+
response_content = http_response.body
|
1139
|
+
unless status_code == 200
|
1140
|
+
error_model = JSON.load(response_content)
|
1141
|
+
fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
|
1142
|
+
end
|
1143
|
+
|
1144
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
1145
|
+
|
1146
|
+
result
|
1147
|
+
end
|
1148
|
+
|
1149
|
+
promise.execute
|
1150
|
+
end
|
1151
|
+
|
1152
|
+
#
|
1153
|
+
# Add a face to a large face list. The input face is specified as an image with
|
1154
|
+
# a targetFace rectangle. It returns a persistedFaceId representing the added
|
1155
|
+
# face, and persistedFaceId will not expire.
|
1156
|
+
#
|
1157
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1158
|
+
# list.
|
1159
|
+
# @param url [String] Publicly reachable URL of an image
|
1160
|
+
# @param user_data [String] User-specified data about the face for any purpose.
|
1161
|
+
# The maximum length is 1KB.
|
1162
|
+
# @param target_face [Array<Integer>] A face rectangle to specify the target
|
1163
|
+
# face to be added to a person in the format of
|
1164
|
+
# "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
|
1165
|
+
# is more than one face in the image, targetFace is required to specify which
|
1166
|
+
# face to add. No targetFace means there is only one face detected in the
|
1167
|
+
# entire image.
|
1168
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1169
|
+
# will be added to the HTTP request.
|
1170
|
+
#
|
1171
|
+
# @return [PersistedFace] operation results.
|
1172
|
+
#
|
1173
|
+
def add_face_from_url(large_face_list_id, url, user_data:nil, target_face:nil, custom_headers:nil)
|
1174
|
+
response = add_face_from_url_async(large_face_list_id, url, user_data:user_data, target_face:target_face, custom_headers:custom_headers).value!
|
1175
|
+
response.body unless response.nil?
|
1176
|
+
end
|
1177
|
+
|
1178
|
+
#
|
1179
|
+
# Add a face to a large face list. The input face is specified as an image with
|
1180
|
+
# a targetFace rectangle. It returns a persistedFaceId representing the added
|
1181
|
+
# face, and persistedFaceId will not expire.
|
1182
|
+
#
|
1183
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1184
|
+
# list.
|
1185
|
+
# @param url [String] Publicly reachable URL of an image
|
1186
|
+
# @param user_data [String] User-specified data about the face for any purpose.
|
1187
|
+
# The maximum length is 1KB.
|
1188
|
+
# @param target_face [Array<Integer>] A face rectangle to specify the target
|
1189
|
+
# face to be added to a person in the format of
|
1190
|
+
# "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
|
1191
|
+
# is more than one face in the image, targetFace is required to specify which
|
1192
|
+
# face to add. No targetFace means there is only one face detected in the
|
1193
|
+
# entire image.
|
1194
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1195
|
+
# will be added to the HTTP request.
|
1196
|
+
#
|
1197
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
1198
|
+
#
|
1199
|
+
def add_face_from_url_with_http_info(large_face_list_id, url, user_data:nil, target_face:nil, custom_headers:nil)
|
1200
|
+
add_face_from_url_async(large_face_list_id, url, user_data:user_data, target_face:target_face, custom_headers:custom_headers).value!
|
1201
|
+
end
|
1202
|
+
|
1203
|
+
#
|
1204
|
+
# Add a face to a large face list. The input face is specified as an image with
|
1205
|
+
# a targetFace rectangle. It returns a persistedFaceId representing the added
|
1206
|
+
# face, and persistedFaceId will not expire.
|
1207
|
+
#
|
1208
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1209
|
+
# list.
|
1210
|
+
# @param url [String] Publicly reachable URL of an image
|
1211
|
+
# @param user_data [String] User-specified data about the face for any purpose.
|
1212
|
+
# The maximum length is 1KB.
|
1213
|
+
# @param target_face [Array<Integer>] A face rectangle to specify the target
|
1214
|
+
# face to be added to a person in the format of
|
1215
|
+
# "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
|
1216
|
+
# is more than one face in the image, targetFace is required to specify which
|
1217
|
+
# face to add. No targetFace means there is only one face detected in the
|
1218
|
+
# entire image.
|
1219
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1220
|
+
# to the HTTP request.
|
1221
|
+
#
|
1222
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1223
|
+
#
|
1224
|
+
def add_face_from_url_async(large_face_list_id, url, user_data:nil, target_face:nil, custom_headers:nil)
|
1225
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
1226
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
1227
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
1228
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
1229
|
+
fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
|
1230
|
+
fail ArgumentError, 'url is nil' if url.nil?
|
1231
|
+
|
1232
|
+
image_url = ImageUrl.new
|
1233
|
+
unless url.nil?
|
1234
|
+
image_url.url = url
|
1235
|
+
end
|
1236
|
+
|
1237
|
+
request_headers = {}
|
1238
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
1239
|
+
|
1240
|
+
# Set Headers
|
1241
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
1242
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
1243
|
+
|
1244
|
+
# Serialize Request
|
1245
|
+
request_mapper = Azure::CognitiveServices::Face::V1_0::Models::ImageUrl.mapper()
|
1246
|
+
request_content = @client.serialize(request_mapper, image_url)
|
1247
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
1248
|
+
|
1249
|
+
path_template = 'largefacelists/{largeFaceListId}/persistedfaces'
|
1250
|
+
|
1251
|
+
request_url = @base_url || @client.base_url
|
1252
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
1253
|
+
|
1254
|
+
options = {
|
1255
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1256
|
+
path_params: {'largeFaceListId' => large_face_list_id},
|
1257
|
+
query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(',')},
|
1258
|
+
body: request_content,
|
1259
|
+
headers: request_headers.merge(custom_headers || {}),
|
1260
|
+
base_url: request_url
|
1261
|
+
}
|
1262
|
+
promise = @client.make_request_async(:post, path_template, options)
|
1263
|
+
|
1264
|
+
promise = promise.then do |result|
|
1265
|
+
http_response = result.response
|
1266
|
+
status_code = http_response.status
|
1267
|
+
response_content = http_response.body
|
1268
|
+
unless status_code == 200
|
1269
|
+
error_model = JSON.load(response_content)
|
1270
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
1271
|
+
end
|
1272
|
+
|
1273
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
1274
|
+
# Deserialize Response
|
1275
|
+
if status_code == 200
|
1276
|
+
begin
|
1277
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
1278
|
+
result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
|
1279
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
1280
|
+
rescue Exception => e
|
1281
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
1282
|
+
end
|
1283
|
+
end
|
1284
|
+
|
1285
|
+
result
|
1286
|
+
end
|
1287
|
+
|
1288
|
+
promise.execute
|
1289
|
+
end
|
1290
|
+
|
1291
|
+
#
|
1292
|
+
# List all faces in a large face list, and retrieve face information (including
|
1293
|
+
# userData and persistedFaceIds of registered faces of the face).
|
1294
|
+
#
|
1295
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1296
|
+
# list.
|
1297
|
+
# @param start [String] Starting face id to return (used to list a range of
|
1298
|
+
# faces).
|
1299
|
+
# @param top [Integer] Number of faces to return starting with the face id
|
1300
|
+
# indicated by the 'start' parameter.
|
1301
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1302
|
+
# will be added to the HTTP request.
|
1303
|
+
#
|
1304
|
+
# @return [Array] operation results.
|
1305
|
+
#
|
1306
|
+
def list_faces(large_face_list_id, start:nil, top:nil, custom_headers:nil)
|
1307
|
+
response = list_faces_async(large_face_list_id, start:start, top:top, custom_headers:custom_headers).value!
|
1308
|
+
response.body unless response.nil?
|
1309
|
+
end
|
1310
|
+
|
1311
|
+
#
|
1312
|
+
# List all faces in a large face list, and retrieve face information (including
|
1313
|
+
# userData and persistedFaceIds of registered faces of the face).
|
1314
|
+
#
|
1315
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1316
|
+
# list.
|
1317
|
+
# @param start [String] Starting face id to return (used to list a range of
|
1318
|
+
# faces).
|
1319
|
+
# @param top [Integer] Number of faces to return starting with the face id
|
1320
|
+
# indicated by the 'start' parameter.
|
1321
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1322
|
+
# will be added to the HTTP request.
|
1323
|
+
#
|
1324
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
1325
|
+
#
|
1326
|
+
def list_faces_with_http_info(large_face_list_id, start:nil, top:nil, custom_headers:nil)
|
1327
|
+
list_faces_async(large_face_list_id, start:start, top:top, custom_headers:custom_headers).value!
|
1328
|
+
end
|
1329
|
+
|
1330
|
+
#
|
1331
|
+
# List all faces in a large face list, and retrieve face information (including
|
1332
|
+
# userData and persistedFaceIds of registered faces of the face).
|
1333
|
+
#
|
1334
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1335
|
+
# list.
|
1336
|
+
# @param start [String] Starting face id to return (used to list a range of
|
1337
|
+
# faces).
|
1338
|
+
# @param top [Integer] Number of faces to return starting with the face id
|
1339
|
+
# indicated by the 'start' parameter.
|
1340
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1341
|
+
# to the HTTP request.
|
1342
|
+
#
|
1343
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1344
|
+
#
|
1345
|
+
def list_faces_async(large_face_list_id, start:nil, top:nil, custom_headers:nil)
|
1346
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
1347
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
1348
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
1349
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
1350
|
+
fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMaximum': '1000'" if !top.nil? && top > 1000
|
1351
|
+
fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMinimum': '1'" if !top.nil? && top < 1
|
1352
|
+
|
1353
|
+
|
1354
|
+
request_headers = {}
|
1355
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
1356
|
+
|
1357
|
+
# Set Headers
|
1358
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
1359
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
1360
|
+
path_template = 'largefacelists/{largeFaceListId}/persistedfaces'
|
1361
|
+
|
1362
|
+
request_url = @base_url || @client.base_url
|
1363
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
1364
|
+
|
1365
|
+
options = {
|
1366
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1367
|
+
path_params: {'largeFaceListId' => large_face_list_id},
|
1368
|
+
query_params: {'start' => start,'top' => top},
|
1369
|
+
headers: request_headers.merge(custom_headers || {}),
|
1370
|
+
base_url: request_url
|
1371
|
+
}
|
1372
|
+
promise = @client.make_request_async(:get, path_template, options)
|
1373
|
+
|
1374
|
+
promise = promise.then do |result|
|
1375
|
+
http_response = result.response
|
1376
|
+
status_code = http_response.status
|
1377
|
+
response_content = http_response.body
|
1378
|
+
unless status_code == 200
|
1379
|
+
error_model = JSON.load(response_content)
|
1380
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
1381
|
+
end
|
1382
|
+
|
1383
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
1384
|
+
# Deserialize Response
|
1385
|
+
if status_code == 200
|
1386
|
+
begin
|
1387
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
1388
|
+
result_mapper = {
|
1389
|
+
client_side_validation: true,
|
1390
|
+
required: false,
|
1391
|
+
serialized_name: 'parsed_response',
|
1392
|
+
type: {
|
1393
|
+
name: 'Sequence',
|
1394
|
+
element: {
|
1395
|
+
client_side_validation: true,
|
1396
|
+
required: false,
|
1397
|
+
serialized_name: 'PersistedFaceElementType',
|
1398
|
+
type: {
|
1399
|
+
name: 'Composite',
|
1400
|
+
class_name: 'PersistedFace'
|
1401
|
+
}
|
1402
|
+
}
|
1403
|
+
}
|
1404
|
+
}
|
1405
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
1406
|
+
rescue Exception => e
|
1407
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
1408
|
+
end
|
1409
|
+
end
|
1410
|
+
|
1411
|
+
result
|
1412
|
+
end
|
1413
|
+
|
1414
|
+
promise.execute
|
1415
|
+
end
|
1416
|
+
|
1417
|
+
#
|
1418
|
+
# Add a face to a large face list. The input face is specified as an image with
|
1419
|
+
# a targetFace rectangle. It returns a persistedFaceId representing the added
|
1420
|
+
# face, and persistedFaceId will not expire.
|
1421
|
+
#
|
1422
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1423
|
+
# list.
|
1424
|
+
# @param image An image stream.
|
1425
|
+
# @param user_data [String] User-specified data about the face for any purpose.
|
1426
|
+
# The maximum length is 1KB.
|
1427
|
+
# @param target_face [Array<Integer>] A face rectangle to specify the target
|
1428
|
+
# face to be added to a person in the format of
|
1429
|
+
# "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
|
1430
|
+
# is more than one face in the image, targetFace is required to specify which
|
1431
|
+
# face to add. No targetFace means there is only one face detected in the
|
1432
|
+
# entire image.
|
1433
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1434
|
+
# will be added to the HTTP request.
|
1435
|
+
#
|
1436
|
+
# @return [PersistedFace] operation results.
|
1437
|
+
#
|
1438
|
+
def add_face_from_stream(large_face_list_id, image, user_data:nil, target_face:nil, custom_headers:nil)
|
1439
|
+
response = add_face_from_stream_async(large_face_list_id, image, user_data:user_data, target_face:target_face, custom_headers:custom_headers).value!
|
1440
|
+
response.body unless response.nil?
|
1441
|
+
end
|
1442
|
+
|
1443
|
+
#
|
1444
|
+
# Add a face to a large face list. The input face is specified as an image with
|
1445
|
+
# a targetFace rectangle. It returns a persistedFaceId representing the added
|
1446
|
+
# face, and persistedFaceId will not expire.
|
1447
|
+
#
|
1448
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1449
|
+
# list.
|
1450
|
+
# @param image An image stream.
|
1451
|
+
# @param user_data [String] User-specified data about the face for any purpose.
|
1452
|
+
# The maximum length is 1KB.
|
1453
|
+
# @param target_face [Array<Integer>] A face rectangle to specify the target
|
1454
|
+
# face to be added to a person in the format of
|
1455
|
+
# "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
|
1456
|
+
# is more than one face in the image, targetFace is required to specify which
|
1457
|
+
# face to add. No targetFace means there is only one face detected in the
|
1458
|
+
# entire image.
|
1459
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
1460
|
+
# will be added to the HTTP request.
|
1461
|
+
#
|
1462
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
1463
|
+
#
|
1464
|
+
def add_face_from_stream_with_http_info(large_face_list_id, image, user_data:nil, target_face:nil, custom_headers:nil)
|
1465
|
+
add_face_from_stream_async(large_face_list_id, image, user_data:user_data, target_face:target_face, custom_headers:custom_headers).value!
|
1466
|
+
end
|
1467
|
+
|
1468
|
+
#
|
1469
|
+
# Add a face to a large face list. The input face is specified as an image with
|
1470
|
+
# a targetFace rectangle. It returns a persistedFaceId representing the added
|
1471
|
+
# face, and persistedFaceId will not expire.
|
1472
|
+
#
|
1473
|
+
# @param large_face_list_id [String] Id referencing a particular large face
|
1474
|
+
# list.
|
1475
|
+
# @param image An image stream.
|
1476
|
+
# @param user_data [String] User-specified data about the face for any purpose.
|
1477
|
+
# The maximum length is 1KB.
|
1478
|
+
# @param target_face [Array<Integer>] A face rectangle to specify the target
|
1479
|
+
# face to be added to a person in the format of
|
1480
|
+
# "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
|
1481
|
+
# is more than one face in the image, targetFace is required to specify which
|
1482
|
+
# face to add. No targetFace means there is only one face detected in the
|
1483
|
+
# entire image.
|
1484
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
1485
|
+
# to the HTTP request.
|
1486
|
+
#
|
1487
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
1488
|
+
#
|
1489
|
+
def add_face_from_stream_async(large_face_list_id, image, user_data:nil, target_face:nil, custom_headers:nil)
|
1490
|
+
fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
|
1491
|
+
fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
|
1492
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
|
1493
|
+
fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_face_list_id.nil? && large_face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
1494
|
+
fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
|
1495
|
+
fail ArgumentError, 'image is nil' if image.nil?
|
1496
|
+
|
1497
|
+
|
1498
|
+
request_headers = {}
|
1499
|
+
request_headers['Content-Type'] = 'application/octet-stream'
|
1500
|
+
|
1501
|
+
# Set Headers
|
1502
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
1503
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
1504
|
+
|
1505
|
+
# Serialize Request
|
1506
|
+
request_mapper = {
|
1507
|
+
client_side_validation: true,
|
1508
|
+
required: true,
|
1509
|
+
serialized_name: 'Image',
|
1510
|
+
type: {
|
1511
|
+
name: 'Stream'
|
1512
|
+
}
|
1513
|
+
}
|
1514
|
+
request_content = @client.serialize(request_mapper, image)
|
1515
|
+
|
1516
|
+
path_template = 'largefacelists/{largeFaceListId}/persistedfaces'
|
1517
|
+
|
1518
|
+
request_url = @base_url || @client.base_url
|
1519
|
+
request_url = request_url.gsub('{Endpoint}', @client.endpoint)
|
1520
|
+
|
1521
|
+
options = {
|
1522
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
1523
|
+
path_params: {'largeFaceListId' => large_face_list_id},
|
1524
|
+
query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(',')},
|
1525
|
+
body: request_content,
|
1526
|
+
headers: request_headers.merge(custom_headers || {}),
|
1527
|
+
base_url: request_url
|
1528
|
+
}
|
1529
|
+
promise = @client.make_request_async(:post, path_template, options)
|
1530
|
+
|
1531
|
+
promise = promise.then do |result|
|
1532
|
+
http_response = result.response
|
1533
|
+
status_code = http_response.status
|
1534
|
+
response_content = http_response.body
|
1535
|
+
unless status_code == 200
|
1536
|
+
error_model = JSON.load(response_content)
|
1537
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
1538
|
+
end
|
1539
|
+
|
1540
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
1541
|
+
# Deserialize Response
|
1542
|
+
if status_code == 200
|
1543
|
+
begin
|
1544
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
1545
|
+
result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
|
1546
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
1547
|
+
rescue Exception => e
|
1548
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
1549
|
+
end
|
1550
|
+
end
|
1551
|
+
|
1552
|
+
result
|
1553
|
+
end
|
1554
|
+
|
1555
|
+
promise.execute
|
1556
|
+
end
|
1557
|
+
|
1558
|
+
end
|
1559
|
+
end
|