be_azure_cognitiveservices_face 0.19.5

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