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,1894 @@
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 - Find
35
+ # Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
36
+ # No image will be stored. Only the extracted face features are stored on
37
+ # server until [LargeFaceList -
38
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
39
+ # is called.
40
+ # <br /> Find Similar is used for scenario like finding celebrity-like faces,
41
+ # similar face filtering, or as a light way face identification. But if the
42
+ # actual use is to identify person, please use
43
+ # [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244)
44
+ # /
45
+ # [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d)
46
+ # and [Face -
47
+ # Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239).
48
+ # <br/>'recognitionModel' should be specified to associate with this large face
49
+ # list. The default value for 'recognitionModel' is 'recognition_01', if the
50
+ # latest model needed, please explicitly specify the model you need in this
51
+ # parameter. New faces that are added to an existing large face list will use
52
+ # the recognition model that's already associated with the collection. Existing
53
+ # face features in a large face list can't be updated to features extracted by
54
+ # another version of recognition model.
55
+ # * 'recognition_01': The default recognition model for [LargeFaceList-
56
+ # Create](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc).
57
+ # All those large face lists created before 2019 March are bonded with this
58
+ # recognition model.
59
+ # * 'recognition_02': Recognition model released in 2019 March.
60
+ # 'recognition_02' is recommended since its overall accuracy is improved
61
+ # compared with 'recognition_01'.
62
+ #
63
+ # Large face list quota:
64
+ # * Free-tier subscription quota: 64 large face lists.
65
+ # * S0-tier subscription quota: 1,000,000 large face lists.
66
+ #
67
+ # @param large_face_list_id [String] Id referencing a particular large face
68
+ # list.
69
+ # @param name [String] User defined name, maximum length is 128.
70
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
71
+ # @param recognition_model [RecognitionModel] Possible values include:
72
+ # 'recognition_01', 'recognition_02'
73
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
74
+ # will be added to the HTTP request.
75
+ #
76
+ #
77
+ def create(large_face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
78
+ response = create_async(large_face_list_id, name:name, user_data:user_data, recognition_model:recognition_model, custom_headers:custom_headers).value!
79
+ nil
80
+ end
81
+
82
+ #
83
+ # Create an empty large face list with user-specified largeFaceListId, name, an
84
+ # optional userData and recognitionModel.
85
+ # <br /> Large face list is a list of faces, up to 1,000,000 faces, and used by
86
+ # [Face - Find
87
+ # Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
88
+ # <br /> After creation, user should use [LargeFaceList Face -
89
+ # Add](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3)
90
+ # to import the faces and [LargeFaceList -
91
+ # Train](/docs/services/563879b61984550e40cbbe8d/operations/5a158422d2de3616c086f2d1)
92
+ # to make it ready for [Face - Find
93
+ # Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
94
+ # No image will be stored. Only the extracted face features are stored on
95
+ # server until [LargeFaceList -
96
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
97
+ # is called.
98
+ # <br /> Find Similar is used for scenario like finding celebrity-like faces,
99
+ # similar face filtering, or as a light way face identification. But if the
100
+ # actual use is to identify person, please use
101
+ # [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244)
102
+ # /
103
+ # [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d)
104
+ # and [Face -
105
+ # Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239).
106
+ # <br/>'recognitionModel' should be specified to associate with this large face
107
+ # list. The default value for 'recognitionModel' is 'recognition_01', if the
108
+ # latest model needed, please explicitly specify the model you need in this
109
+ # parameter. New faces that are added to an existing large face list will use
110
+ # the recognition model that's already associated with the collection. Existing
111
+ # face features in a large face list can't be updated to features extracted by
112
+ # another version of recognition model.
113
+ # * 'recognition_01': The default recognition model for [LargeFaceList-
114
+ # Create](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc).
115
+ # All those large face lists created before 2019 March are bonded with this
116
+ # recognition model.
117
+ # * 'recognition_02': Recognition model released in 2019 March.
118
+ # 'recognition_02' is recommended since its overall accuracy is improved
119
+ # compared with 'recognition_01'.
120
+ #
121
+ # Large face list quota:
122
+ # * Free-tier subscription quota: 64 large face lists.
123
+ # * S0-tier subscription quota: 1,000,000 large face lists.
124
+ #
125
+ # @param large_face_list_id [String] Id referencing a particular large face
126
+ # list.
127
+ # @param name [String] User defined name, maximum length is 128.
128
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
129
+ # @param recognition_model [RecognitionModel] Possible values include:
130
+ # 'recognition_01', 'recognition_02'
131
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
132
+ # will be added to the HTTP request.
133
+ #
134
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
135
+ #
136
+ def create_with_http_info(large_face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
137
+ create_async(large_face_list_id, name:name, user_data:user_data, recognition_model:recognition_model, custom_headers:custom_headers).value!
138
+ end
139
+
140
+ #
141
+ # Create an empty large face list with user-specified largeFaceListId, name, an
142
+ # optional userData and recognitionModel.
143
+ # <br /> Large face list is a list of faces, up to 1,000,000 faces, and used by
144
+ # [Face - Find
145
+ # Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
146
+ # <br /> After creation, user should use [LargeFaceList Face -
147
+ # Add](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3)
148
+ # to import the faces and [LargeFaceList -
149
+ # Train](/docs/services/563879b61984550e40cbbe8d/operations/5a158422d2de3616c086f2d1)
150
+ # to make it ready for [Face - Find
151
+ # Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
152
+ # No image will be stored. Only the extracted face features are stored on
153
+ # server until [LargeFaceList -
154
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
155
+ # is called.
156
+ # <br /> Find Similar is used for scenario like finding celebrity-like faces,
157
+ # similar face filtering, or as a light way face identification. But if the
158
+ # actual use is to identify person, please use
159
+ # [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244)
160
+ # /
161
+ # [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d)
162
+ # and [Face -
163
+ # Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239).
164
+ # <br/>'recognitionModel' should be specified to associate with this large face
165
+ # list. The default value for 'recognitionModel' is 'recognition_01', if the
166
+ # latest model needed, please explicitly specify the model you need in this
167
+ # parameter. New faces that are added to an existing large face list will use
168
+ # the recognition model that's already associated with the collection. Existing
169
+ # face features in a large face list can't be updated to features extracted by
170
+ # another version of recognition model.
171
+ # * 'recognition_01': The default recognition model for [LargeFaceList-
172
+ # Create](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc).
173
+ # All those large face lists created before 2019 March are bonded with this
174
+ # recognition model.
175
+ # * 'recognition_02': Recognition model released in 2019 March.
176
+ # 'recognition_02' is recommended since its overall accuracy is improved
177
+ # compared with 'recognition_01'.
178
+ #
179
+ # Large face list quota:
180
+ # * Free-tier subscription quota: 64 large face lists.
181
+ # * S0-tier subscription quota: 1,000,000 large face lists.
182
+ #
183
+ # @param large_face_list_id [String] Id referencing a particular large face
184
+ # list.
185
+ # @param name [String] User defined name, maximum length is 128.
186
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
187
+ # @param recognition_model [RecognitionModel] Possible values include:
188
+ # 'recognition_01', 'recognition_02'
189
+ # @param [Hash{String => String}] A hash of custom headers that will be added
190
+ # to the HTTP request.
191
+ #
192
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
193
+ #
194
+ def create_async(large_face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
195
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
196
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
197
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
198
+ 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?
199
+ fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
200
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384
201
+
202
+ body = MetaDataContract.new
203
+ unless name.nil? && user_data.nil? && recognition_model.nil?
204
+ body.name = name
205
+ body.user_data = user_data
206
+ body.recognition_model = recognition_model
207
+ end
208
+
209
+ request_headers = {}
210
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
211
+
212
+ # Set Headers
213
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
214
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
215
+
216
+ # Serialize Request
217
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::MetaDataContract.mapper()
218
+ request_content = @client.serialize(request_mapper, body)
219
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
220
+
221
+ path_template = 'largefacelists/{largeFaceListId}'
222
+
223
+ request_url = @base_url || @client.base_url
224
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
225
+
226
+ options = {
227
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
228
+ path_params: {'largeFaceListId' => large_face_list_id},
229
+ body: request_content,
230
+ headers: request_headers.merge(custom_headers || {}),
231
+ base_url: request_url
232
+ }
233
+ promise = @client.make_request_async(:put, path_template, options)
234
+
235
+ promise = promise.then do |result|
236
+ http_response = result.response
237
+ status_code = http_response.status
238
+ response_content = http_response.body
239
+ unless status_code == 200
240
+ error_model = JSON.load(response_content)
241
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
242
+ end
243
+
244
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
245
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
246
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
247
+
248
+ result
249
+ end
250
+
251
+ promise.execute
252
+ end
253
+
254
+ #
255
+ # Retrieve a large face list’s largeFaceListId, name, userData and
256
+ # recognitionModel.
257
+ #
258
+ # @param large_face_list_id [String] Id referencing a particular large face
259
+ # list.
260
+ # @param return_recognition_model [Boolean] A value indicating whether the
261
+ # operation should return 'recognitionModel' in response.
262
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
263
+ # will be added to the HTTP request.
264
+ #
265
+ # @return [LargeFaceList] operation results.
266
+ #
267
+ def get(large_face_list_id, return_recognition_model:false, custom_headers:nil)
268
+ response = get_async(large_face_list_id, return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
269
+ response.body unless response.nil?
270
+ end
271
+
272
+ #
273
+ # Retrieve a large face list’s largeFaceListId, name, userData and
274
+ # recognitionModel.
275
+ #
276
+ # @param large_face_list_id [String] Id referencing a particular large face
277
+ # list.
278
+ # @param return_recognition_model [Boolean] A value indicating whether the
279
+ # operation should return 'recognitionModel' in response.
280
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
281
+ # will be added to the HTTP request.
282
+ #
283
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
284
+ #
285
+ def get_with_http_info(large_face_list_id, return_recognition_model:false, custom_headers:nil)
286
+ get_async(large_face_list_id, return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
287
+ end
288
+
289
+ #
290
+ # Retrieve a large face list’s largeFaceListId, name, userData and
291
+ # recognitionModel.
292
+ #
293
+ # @param large_face_list_id [String] Id referencing a particular large face
294
+ # list.
295
+ # @param return_recognition_model [Boolean] A value indicating whether the
296
+ # operation should return 'recognitionModel' in response.
297
+ # @param [Hash{String => String}] A hash of custom headers that will be added
298
+ # to the HTTP request.
299
+ #
300
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
301
+ #
302
+ def get_async(large_face_list_id, return_recognition_model:false, custom_headers:nil)
303
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
304
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
305
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
306
+ 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?
307
+
308
+
309
+ request_headers = {}
310
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
311
+
312
+ # Set Headers
313
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
314
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
315
+ path_template = 'largefacelists/{largeFaceListId}'
316
+
317
+ request_url = @base_url || @client.base_url
318
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
319
+
320
+ options = {
321
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
322
+ path_params: {'largeFaceListId' => large_face_list_id},
323
+ query_params: {'returnRecognitionModel' => return_recognition_model},
324
+ headers: request_headers.merge(custom_headers || {}),
325
+ base_url: request_url
326
+ }
327
+ promise = @client.make_request_async(:get, path_template, options)
328
+
329
+ promise = promise.then do |result|
330
+ http_response = result.response
331
+ status_code = http_response.status
332
+ response_content = http_response.body
333
+ unless status_code == 200
334
+ error_model = JSON.load(response_content)
335
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
336
+ end
337
+
338
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
339
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
340
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
341
+ # Deserialize Response
342
+ if status_code == 200
343
+ begin
344
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
345
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::LargeFaceList.mapper()
346
+ result.body = @client.deserialize(result_mapper, parsed_response)
347
+ rescue Exception => e
348
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
349
+ end
350
+ end
351
+
352
+ result
353
+ end
354
+
355
+ promise.execute
356
+ end
357
+
358
+ #
359
+ # Update information of a large face list.
360
+ #
361
+ # @param large_face_list_id [String] Id referencing a particular large face
362
+ # list.
363
+ # @param name [String] User defined name, maximum length is 128.
364
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
365
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
366
+ # will be added to the HTTP request.
367
+ #
368
+ #
369
+ def update(large_face_list_id, name:nil, user_data:nil, custom_headers:nil)
370
+ response = update_async(large_face_list_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
371
+ nil
372
+ end
373
+
374
+ #
375
+ # Update information of a large face list.
376
+ #
377
+ # @param large_face_list_id [String] Id referencing a particular large face
378
+ # list.
379
+ # @param name [String] User defined name, maximum length is 128.
380
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
381
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
382
+ # will be added to the HTTP request.
383
+ #
384
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
385
+ #
386
+ def update_with_http_info(large_face_list_id, name:nil, user_data:nil, custom_headers:nil)
387
+ update_async(large_face_list_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
388
+ end
389
+
390
+ #
391
+ # Update information of a large face list.
392
+ #
393
+ # @param large_face_list_id [String] Id referencing a particular large face
394
+ # list.
395
+ # @param name [String] User defined name, maximum length is 128.
396
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
397
+ # @param [Hash{String => String}] A hash of custom headers that will be added
398
+ # to the HTTP request.
399
+ #
400
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
401
+ #
402
+ def update_async(large_face_list_id, name:nil, user_data:nil, custom_headers:nil)
403
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
404
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
405
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
406
+ 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?
407
+ fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
408
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384
409
+
410
+ body = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.new
411
+ unless name.nil? && user_data.nil?
412
+ body.name = name
413
+ body.user_data = user_data
414
+ end
415
+
416
+ request_headers = {}
417
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
418
+
419
+ # Set Headers
420
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
421
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
422
+
423
+ # Serialize Request
424
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.mapper()
425
+ request_content = @client.serialize(request_mapper, body)
426
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
427
+
428
+ path_template = 'largefacelists/{largeFaceListId}'
429
+
430
+ request_url = @base_url || @client.base_url
431
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
432
+
433
+ options = {
434
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
435
+ path_params: {'largeFaceListId' => large_face_list_id},
436
+ body: request_content,
437
+ headers: request_headers.merge(custom_headers || {}),
438
+ base_url: request_url
439
+ }
440
+ promise = @client.make_request_async(:patch, path_template, options)
441
+
442
+ promise = promise.then do |result|
443
+ http_response = result.response
444
+ status_code = http_response.status
445
+ response_content = http_response.body
446
+ unless status_code == 200
447
+ error_model = JSON.load(response_content)
448
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
449
+ end
450
+
451
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
452
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
453
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
454
+
455
+ result
456
+ end
457
+
458
+ promise.execute
459
+ end
460
+
461
+ #
462
+ # Delete a specified large face list.
463
+ #
464
+ # @param large_face_list_id [String] Id referencing a particular large face
465
+ # list.
466
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
467
+ # will be added to the HTTP request.
468
+ #
469
+ #
470
+ def delete(large_face_list_id, custom_headers:nil)
471
+ response = delete_async(large_face_list_id, custom_headers:custom_headers).value!
472
+ nil
473
+ end
474
+
475
+ #
476
+ # Delete a specified large face list.
477
+ #
478
+ # @param large_face_list_id [String] Id referencing a particular large face
479
+ # list.
480
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
481
+ # will be added to the HTTP request.
482
+ #
483
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
484
+ #
485
+ def delete_with_http_info(large_face_list_id, custom_headers:nil)
486
+ delete_async(large_face_list_id, custom_headers:custom_headers).value!
487
+ end
488
+
489
+ #
490
+ # Delete a specified large face list.
491
+ #
492
+ # @param large_face_list_id [String] Id referencing a particular large face
493
+ # list.
494
+ # @param [Hash{String => String}] A hash of custom headers that will be added
495
+ # to the HTTP request.
496
+ #
497
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
498
+ #
499
+ def delete_async(large_face_list_id, custom_headers:nil)
500
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
501
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
502
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
503
+ 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?
504
+
505
+
506
+ request_headers = {}
507
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
508
+
509
+ # Set Headers
510
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
511
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
512
+ path_template = 'largefacelists/{largeFaceListId}'
513
+
514
+ request_url = @base_url || @client.base_url
515
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
516
+
517
+ options = {
518
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
519
+ path_params: {'largeFaceListId' => large_face_list_id},
520
+ headers: request_headers.merge(custom_headers || {}),
521
+ base_url: request_url
522
+ }
523
+ promise = @client.make_request_async(:delete, path_template, options)
524
+
525
+ promise = promise.then do |result|
526
+ http_response = result.response
527
+ status_code = http_response.status
528
+ response_content = http_response.body
529
+ unless status_code == 200
530
+ error_model = JSON.load(response_content)
531
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
532
+ end
533
+
534
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
535
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
536
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
537
+
538
+ result
539
+ end
540
+
541
+ promise.execute
542
+ end
543
+
544
+ #
545
+ # Retrieve the training status of a large face list (completed or ongoing).
546
+ #
547
+ # @param large_face_list_id [String] Id referencing a particular large face
548
+ # list.
549
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
550
+ # will be added to the HTTP request.
551
+ #
552
+ # @return [TrainingStatus] operation results.
553
+ #
554
+ def get_training_status(large_face_list_id, custom_headers:nil)
555
+ response = get_training_status_async(large_face_list_id, custom_headers:custom_headers).value!
556
+ response.body unless response.nil?
557
+ end
558
+
559
+ #
560
+ # Retrieve the training status of a large face list (completed or ongoing).
561
+ #
562
+ # @param large_face_list_id [String] Id referencing a particular large face
563
+ # list.
564
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
565
+ # will be added to the HTTP request.
566
+ #
567
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
568
+ #
569
+ def get_training_status_with_http_info(large_face_list_id, custom_headers:nil)
570
+ get_training_status_async(large_face_list_id, custom_headers:custom_headers).value!
571
+ end
572
+
573
+ #
574
+ # Retrieve the training status of a large face list (completed or ongoing).
575
+ #
576
+ # @param large_face_list_id [String] Id referencing a particular large face
577
+ # list.
578
+ # @param [Hash{String => String}] A hash of custom headers that will be added
579
+ # to the HTTP request.
580
+ #
581
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
582
+ #
583
+ def get_training_status_async(large_face_list_id, custom_headers:nil)
584
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
585
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
586
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
587
+ 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?
588
+
589
+
590
+ request_headers = {}
591
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
592
+
593
+ # Set Headers
594
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
595
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
596
+ path_template = 'largefacelists/{largeFaceListId}/training'
597
+
598
+ request_url = @base_url || @client.base_url
599
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
600
+
601
+ options = {
602
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
603
+ path_params: {'largeFaceListId' => large_face_list_id},
604
+ headers: request_headers.merge(custom_headers || {}),
605
+ base_url: request_url
606
+ }
607
+ promise = @client.make_request_async(:get, path_template, options)
608
+
609
+ promise = promise.then do |result|
610
+ http_response = result.response
611
+ status_code = http_response.status
612
+ response_content = http_response.body
613
+ unless status_code == 200
614
+ error_model = JSON.load(response_content)
615
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
616
+ end
617
+
618
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
619
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
620
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
621
+ # Deserialize Response
622
+ if status_code == 200
623
+ begin
624
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
625
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::TrainingStatus.mapper()
626
+ result.body = @client.deserialize(result_mapper, parsed_response)
627
+ rescue Exception => e
628
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
629
+ end
630
+ end
631
+
632
+ result
633
+ end
634
+
635
+ promise.execute
636
+ end
637
+
638
+ #
639
+ # List large face lists’ information of largeFaceListId, name, userData and
640
+ # recognitionModel. <br />
641
+ # To get face information inside largeFaceList use [LargeFaceList Face -
642
+ # Get](/docs/services/563879b61984550e40cbbe8d/operations/5a158cf2d2de3616c086f2d5)<br
643
+ # />
644
+ # * Large face lists are stored in alphabetical order of largeFaceListId.
645
+ # * "start" parameter (string, optional) is a user-provided largeFaceListId
646
+ # value that returned entries have larger ids by string comparison. "start" set
647
+ # to empty to indicate return from the first item.
648
+ # * "top" parameter (int, optional) specifies the number of entries to return.
649
+ # A maximal of 1000 entries can be returned in one call. To fetch more, you can
650
+ # specify "start" with the last returned entry’s Id of the current call.
651
+ # <br />
652
+ # For example, total 5 large person lists: "list1", ..., "list5".
653
+ # <br /> "start=&top=" will return all 5 lists.
654
+ # <br /> "start=&top=2" will return "list1", "list2".
655
+ # <br /> "start=list2&top=3" will return "list3", "list4", "list5".
656
+ #
657
+ #
658
+ # @param return_recognition_model [Boolean] A value indicating whether the
659
+ # operation should return 'recognitionModel' in response.
660
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
661
+ # will be added to the HTTP request.
662
+ #
663
+ # @return [Array] operation results.
664
+ #
665
+ def list(return_recognition_model:false, custom_headers:nil)
666
+ response = list_async(return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
667
+ response.body unless response.nil?
668
+ end
669
+
670
+ #
671
+ # List large face lists’ information of largeFaceListId, name, userData and
672
+ # recognitionModel. <br />
673
+ # To get face information inside largeFaceList use [LargeFaceList Face -
674
+ # Get](/docs/services/563879b61984550e40cbbe8d/operations/5a158cf2d2de3616c086f2d5)<br
675
+ # />
676
+ # * Large face lists are stored in alphabetical order of largeFaceListId.
677
+ # * "start" parameter (string, optional) is a user-provided largeFaceListId
678
+ # value that returned entries have larger ids by string comparison. "start" set
679
+ # to empty to indicate return from the first item.
680
+ # * "top" parameter (int, optional) specifies the number of entries to return.
681
+ # A maximal of 1000 entries can be returned in one call. To fetch more, you can
682
+ # specify "start" with the last returned entry’s Id of the current call.
683
+ # <br />
684
+ # For example, total 5 large person lists: "list1", ..., "list5".
685
+ # <br /> "start=&top=" will return all 5 lists.
686
+ # <br /> "start=&top=2" will return "list1", "list2".
687
+ # <br /> "start=list2&top=3" will return "list3", "list4", "list5".
688
+ #
689
+ #
690
+ # @param return_recognition_model [Boolean] A value indicating whether the
691
+ # operation should return 'recognitionModel' in response.
692
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
693
+ # will be added to the HTTP request.
694
+ #
695
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
696
+ #
697
+ def list_with_http_info(return_recognition_model:false, custom_headers:nil)
698
+ list_async(return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
699
+ end
700
+
701
+ #
702
+ # List large face lists’ information of largeFaceListId, name, userData and
703
+ # recognitionModel. <br />
704
+ # To get face information inside largeFaceList use [LargeFaceList Face -
705
+ # Get](/docs/services/563879b61984550e40cbbe8d/operations/5a158cf2d2de3616c086f2d5)<br
706
+ # />
707
+ # * Large face lists are stored in alphabetical order of largeFaceListId.
708
+ # * "start" parameter (string, optional) is a user-provided largeFaceListId
709
+ # value that returned entries have larger ids by string comparison. "start" set
710
+ # to empty to indicate return from the first item.
711
+ # * "top" parameter (int, optional) specifies the number of entries to return.
712
+ # A maximal of 1000 entries can be returned in one call. To fetch more, you can
713
+ # specify "start" with the last returned entry’s Id of the current call.
714
+ # <br />
715
+ # For example, total 5 large person lists: "list1", ..., "list5".
716
+ # <br /> "start=&top=" will return all 5 lists.
717
+ # <br /> "start=&top=2" will return "list1", "list2".
718
+ # <br /> "start=list2&top=3" will return "list3", "list4", "list5".
719
+ #
720
+ #
721
+ # @param return_recognition_model [Boolean] A value indicating whether the
722
+ # operation should return 'recognitionModel' in response.
723
+ # @param [Hash{String => String}] A hash of custom headers that will be added
724
+ # to the HTTP request.
725
+ #
726
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
727
+ #
728
+ def list_async(return_recognition_model:false, custom_headers:nil)
729
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
730
+
731
+
732
+ request_headers = {}
733
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
734
+
735
+ # Set Headers
736
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
737
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
738
+ path_template = 'largefacelists'
739
+
740
+ request_url = @base_url || @client.base_url
741
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
742
+
743
+ options = {
744
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
745
+ query_params: {'returnRecognitionModel' => return_recognition_model},
746
+ headers: request_headers.merge(custom_headers || {}),
747
+ base_url: request_url
748
+ }
749
+ promise = @client.make_request_async(:get, path_template, options)
750
+
751
+ promise = promise.then do |result|
752
+ http_response = result.response
753
+ status_code = http_response.status
754
+ response_content = http_response.body
755
+ unless status_code == 200
756
+ error_model = JSON.load(response_content)
757
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
758
+ end
759
+
760
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
761
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
762
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
763
+ # Deserialize Response
764
+ if status_code == 200
765
+ begin
766
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
767
+ result_mapper = {
768
+ client_side_validation: true,
769
+ required: false,
770
+ serialized_name: 'parsed_response',
771
+ type: {
772
+ name: 'Sequence',
773
+ element: {
774
+ client_side_validation: true,
775
+ required: false,
776
+ serialized_name: 'LargeFaceListElementType',
777
+ type: {
778
+ name: 'Composite',
779
+ class_name: 'LargeFaceList'
780
+ }
781
+ }
782
+ }
783
+ }
784
+ result.body = @client.deserialize(result_mapper, parsed_response)
785
+ rescue Exception => e
786
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
787
+ end
788
+ end
789
+
790
+ result
791
+ end
792
+
793
+ promise.execute
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 custom_headers [Hash{String => String}] A hash of custom headers that
803
+ # will be added to the HTTP request.
804
+ #
805
+ #
806
+ def train(large_face_list_id, custom_headers:nil)
807
+ response = train_async(large_face_list_id, custom_headers:custom_headers).value!
808
+ nil
809
+ end
810
+
811
+ #
812
+ # Queue a large face list training task, the training task may not be started
813
+ # immediately.
814
+ #
815
+ # @param large_face_list_id [String] Id referencing a particular large face
816
+ # list.
817
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
818
+ # will be added to the HTTP request.
819
+ #
820
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
821
+ #
822
+ def train_with_http_info(large_face_list_id, custom_headers:nil)
823
+ train_async(large_face_list_id, custom_headers:custom_headers).value!
824
+ end
825
+
826
+ #
827
+ # Queue a large face list training task, the training task may not be started
828
+ # immediately.
829
+ #
830
+ # @param large_face_list_id [String] Id referencing a particular large face
831
+ # list.
832
+ # @param [Hash{String => String}] A hash of custom headers that will be added
833
+ # to the HTTP request.
834
+ #
835
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
836
+ #
837
+ def train_async(large_face_list_id, custom_headers:nil)
838
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
839
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
840
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
841
+ 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?
842
+
843
+
844
+ request_headers = {}
845
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
846
+
847
+ # Set Headers
848
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
849
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
850
+ path_template = 'largefacelists/{largeFaceListId}/train'
851
+
852
+ request_url = @base_url || @client.base_url
853
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
854
+
855
+ options = {
856
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
857
+ path_params: {'largeFaceListId' => large_face_list_id},
858
+ headers: request_headers.merge(custom_headers || {}),
859
+ base_url: request_url
860
+ }
861
+ promise = @client.make_request_async(:post, path_template, options)
862
+
863
+ promise = promise.then do |result|
864
+ http_response = result.response
865
+ status_code = http_response.status
866
+ response_content = http_response.body
867
+ unless status_code == 202
868
+ error_model = JSON.load(response_content)
869
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
870
+ end
871
+
872
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
873
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
874
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
875
+
876
+ result
877
+ end
878
+
879
+ promise.execute
880
+ end
881
+
882
+ #
883
+ # Delete a face from a large face list by specified largeFaceListId and
884
+ # persistedFaceId.
885
+ # <br /> Adding/deleting faces to/from a same large face list are processed
886
+ # sequentially and to/from different large face lists are in parallel.
887
+ #
888
+ # @param large_face_list_id [String] Id referencing a particular large face
889
+ # list.
890
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
891
+ # existing face.
892
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
893
+ # will be added to the HTTP request.
894
+ #
895
+ #
896
+ def delete_face(large_face_list_id, persisted_face_id, custom_headers:nil)
897
+ response = delete_face_async(large_face_list_id, persisted_face_id, custom_headers:custom_headers).value!
898
+ nil
899
+ end
900
+
901
+ #
902
+ # Delete a face from a large face list by specified largeFaceListId and
903
+ # persistedFaceId.
904
+ # <br /> Adding/deleting faces to/from a same large face list are processed
905
+ # sequentially and to/from different large face lists are in parallel.
906
+ #
907
+ # @param large_face_list_id [String] Id referencing a particular large face
908
+ # list.
909
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
910
+ # existing face.
911
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
912
+ # will be added to the HTTP request.
913
+ #
914
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
915
+ #
916
+ def delete_face_with_http_info(large_face_list_id, persisted_face_id, custom_headers:nil)
917
+ delete_face_async(large_face_list_id, persisted_face_id, custom_headers:custom_headers).value!
918
+ end
919
+
920
+ #
921
+ # Delete a face from a large face list by specified largeFaceListId and
922
+ # persistedFaceId.
923
+ # <br /> Adding/deleting faces to/from a same large face list are processed
924
+ # sequentially and to/from different large face lists are in parallel.
925
+ #
926
+ # @param large_face_list_id [String] Id referencing a particular large face
927
+ # list.
928
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
929
+ # existing face.
930
+ # @param [Hash{String => String}] A hash of custom headers that will be added
931
+ # to the HTTP request.
932
+ #
933
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
934
+ #
935
+ def delete_face_async(large_face_list_id, persisted_face_id, custom_headers:nil)
936
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
937
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
938
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
939
+ 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?
940
+ fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
941
+
942
+
943
+ request_headers = {}
944
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
945
+
946
+ # Set Headers
947
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
948
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
949
+ path_template = 'largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'
950
+
951
+ request_url = @base_url || @client.base_url
952
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
953
+
954
+ options = {
955
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
956
+ path_params: {'largeFaceListId' => large_face_list_id,'persistedFaceId' => persisted_face_id},
957
+ headers: request_headers.merge(custom_headers || {}),
958
+ base_url: request_url
959
+ }
960
+ promise = @client.make_request_async(:delete, path_template, options)
961
+
962
+ promise = promise.then do |result|
963
+ http_response = result.response
964
+ status_code = http_response.status
965
+ response_content = http_response.body
966
+ unless status_code == 200
967
+ error_model = JSON.load(response_content)
968
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
969
+ end
970
+
971
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
972
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
973
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
974
+
975
+ result
976
+ end
977
+
978
+ promise.execute
979
+ end
980
+
981
+ #
982
+ # Retrieve information about a persisted face (specified by persistedFaceId and
983
+ # its belonging largeFaceListId).
984
+ #
985
+ # @param large_face_list_id [String] Id referencing a particular large face
986
+ # list.
987
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
988
+ # existing face.
989
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
990
+ # will be added to the HTTP request.
991
+ #
992
+ # @return [PersistedFace] operation results.
993
+ #
994
+ def get_face(large_face_list_id, persisted_face_id, custom_headers:nil)
995
+ response = get_face_async(large_face_list_id, persisted_face_id, custom_headers:custom_headers).value!
996
+ response.body unless response.nil?
997
+ end
998
+
999
+ #
1000
+ # Retrieve information about a persisted face (specified by persistedFaceId and
1001
+ # its belonging largeFaceListId).
1002
+ #
1003
+ # @param large_face_list_id [String] Id referencing a particular large face
1004
+ # list.
1005
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
1006
+ # existing face.
1007
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1008
+ # will be added to the HTTP request.
1009
+ #
1010
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1011
+ #
1012
+ def get_face_with_http_info(large_face_list_id, persisted_face_id, custom_headers:nil)
1013
+ get_face_async(large_face_list_id, persisted_face_id, custom_headers:custom_headers).value!
1014
+ end
1015
+
1016
+ #
1017
+ # Retrieve information about a persisted face (specified by persistedFaceId and
1018
+ # its belonging largeFaceListId).
1019
+ #
1020
+ # @param large_face_list_id [String] Id referencing a particular large face
1021
+ # list.
1022
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
1023
+ # existing face.
1024
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1025
+ # to the HTTP request.
1026
+ #
1027
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1028
+ #
1029
+ def get_face_async(large_face_list_id, persisted_face_id, custom_headers:nil)
1030
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
1031
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
1032
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
1033
+ 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?
1034
+ fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
1035
+
1036
+
1037
+ request_headers = {}
1038
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1039
+
1040
+ # Set Headers
1041
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1042
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1043
+ path_template = 'largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'
1044
+
1045
+ request_url = @base_url || @client.base_url
1046
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
1047
+
1048
+ options = {
1049
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1050
+ path_params: {'largeFaceListId' => large_face_list_id,'persistedFaceId' => persisted_face_id},
1051
+ headers: request_headers.merge(custom_headers || {}),
1052
+ base_url: request_url
1053
+ }
1054
+ promise = @client.make_request_async(:get, path_template, options)
1055
+
1056
+ promise = promise.then do |result|
1057
+ http_response = result.response
1058
+ status_code = http_response.status
1059
+ response_content = http_response.body
1060
+ unless status_code == 200
1061
+ error_model = JSON.load(response_content)
1062
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1063
+ end
1064
+
1065
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1066
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1067
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1068
+ # Deserialize Response
1069
+ if status_code == 200
1070
+ begin
1071
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1072
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
1073
+ result.body = @client.deserialize(result_mapper, parsed_response)
1074
+ rescue Exception => e
1075
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1076
+ end
1077
+ end
1078
+
1079
+ result
1080
+ end
1081
+
1082
+ promise.execute
1083
+ end
1084
+
1085
+ #
1086
+ # Update a persisted face's userData field.
1087
+ #
1088
+ # @param large_face_list_id [String] Id referencing a particular large face
1089
+ # list.
1090
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
1091
+ # existing face.
1092
+ # @param user_data [String] User-provided data attached to the face. The size
1093
+ # limit is 1KB.
1094
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1095
+ # will be added to the HTTP request.
1096
+ #
1097
+ #
1098
+ def update_face(large_face_list_id, persisted_face_id, user_data:nil, custom_headers:nil)
1099
+ response = update_face_async(large_face_list_id, persisted_face_id, user_data:user_data, custom_headers:custom_headers).value!
1100
+ nil
1101
+ end
1102
+
1103
+ #
1104
+ # Update a persisted face's userData field.
1105
+ #
1106
+ # @param large_face_list_id [String] Id referencing a particular large face
1107
+ # list.
1108
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
1109
+ # existing face.
1110
+ # @param user_data [String] User-provided data attached to the face. The size
1111
+ # limit is 1KB.
1112
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1113
+ # will be added to the HTTP request.
1114
+ #
1115
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1116
+ #
1117
+ def update_face_with_http_info(large_face_list_id, persisted_face_id, user_data:nil, custom_headers:nil)
1118
+ update_face_async(large_face_list_id, persisted_face_id, user_data:user_data, custom_headers:custom_headers).value!
1119
+ end
1120
+
1121
+ #
1122
+ # Update a persisted face's userData field.
1123
+ #
1124
+ # @param large_face_list_id [String] Id referencing a particular large face
1125
+ # list.
1126
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
1127
+ # existing face.
1128
+ # @param user_data [String] User-provided data attached to the face. The size
1129
+ # limit is 1KB.
1130
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1131
+ # to the HTTP request.
1132
+ #
1133
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1134
+ #
1135
+ def update_face_async(large_face_list_id, persisted_face_id, user_data:nil, custom_headers:nil)
1136
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
1137
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
1138
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
1139
+ 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?
1140
+ fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
1141
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
1142
+
1143
+ body = UpdateFaceRequest.new
1144
+ unless user_data.nil?
1145
+ body.user_data = user_data
1146
+ end
1147
+
1148
+ request_headers = {}
1149
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1150
+
1151
+ # Set Headers
1152
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1153
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1154
+
1155
+ # Serialize Request
1156
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::UpdateFaceRequest.mapper()
1157
+ request_content = @client.serialize(request_mapper, body)
1158
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
1159
+
1160
+ path_template = 'largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'
1161
+
1162
+ request_url = @base_url || @client.base_url
1163
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
1164
+
1165
+ options = {
1166
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1167
+ path_params: {'largeFaceListId' => large_face_list_id,'persistedFaceId' => persisted_face_id},
1168
+ body: request_content,
1169
+ headers: request_headers.merge(custom_headers || {}),
1170
+ base_url: request_url
1171
+ }
1172
+ promise = @client.make_request_async(:patch, path_template, options)
1173
+
1174
+ promise = promise.then do |result|
1175
+ http_response = result.response
1176
+ status_code = http_response.status
1177
+ response_content = http_response.body
1178
+ unless status_code == 200
1179
+ error_model = JSON.load(response_content)
1180
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1181
+ end
1182
+
1183
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1184
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1185
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1186
+
1187
+ result
1188
+ end
1189
+
1190
+ promise.execute
1191
+ end
1192
+
1193
+ #
1194
+ # Add a face to a specified large face list, up to 1,000,000 faces.
1195
+ # <br /> To deal with an image contains multiple faces, input face can be
1196
+ # specified as an image with a targetFace rectangle. It returns a
1197
+ # persistedFaceId representing the added face. No image will be stored. Only
1198
+ # the extracted face feature will be stored on server until [LargeFaceList Face
1199
+ # -
1200
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a158c8ad2de3616c086f2d4)
1201
+ # or [LargeFaceList -
1202
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
1203
+ # is called.
1204
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
1205
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
1206
+ # * Higher face image quality means better recognition precision. Please
1207
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
1208
+ # (100 pixels between eyes) or bigger.
1209
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
1210
+ # image file size is from 1KB to 6MB.
1211
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
1212
+ # be regarded as an error. If the provided "targetFace" rectangle is not
1213
+ # returned from [Face -
1214
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
1215
+ # there’s no guarantee to detect and add the face successfully.
1216
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
1217
+ # large occlusions will cause failures.
1218
+ # * Adding/deleting faces to/from a same face list are processed sequentially
1219
+ # and to/from different face lists are in parallel.
1220
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1221
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1222
+ # need a proportionally larger minimum face size.
1223
+ # * Different 'detectionModel' values can be provided. To use and compare
1224
+ # different detection models, please refer to [How to specify a detection
1225
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1226
+ # | Model | Recommended use-case(s) |
1227
+ # | ---------- | -------- |
1228
+ # | 'detection_01': | The default detection model for [LargeFaceList - Add
1229
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3).
1230
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1231
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1232
+ # faces in such cases may not be detected. |
1233
+ # | 'detection_02': | Detection model released in 2019 May with improved
1234
+ # accuracy especially on small, side and blurry faces. |
1235
+ #
1236
+ # Quota:
1237
+ # * Free-tier subscription quota: 1,000 faces per large face list.
1238
+ # * S0-tier subscription quota: 1,000,000 faces per large face list.
1239
+ #
1240
+ # @param large_face_list_id [String] Id referencing a particular large face
1241
+ # list.
1242
+ # @param url [String] Publicly reachable URL of an image
1243
+ # @param user_data [String] User-specified data about the face for any purpose.
1244
+ # The maximum length is 1KB.
1245
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1246
+ # face to be added to a person in the format of
1247
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1248
+ # is more than one face in the image, targetFace is required to specify which
1249
+ # face to add. No targetFace means there is only one face detected in the
1250
+ # entire image.
1251
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1252
+ # model is used to detect faces in the submitted image. A detection model name
1253
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1254
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1255
+ # another model is needed, please explicitly specify it. Possible values
1256
+ # include: 'detection_01', 'detection_02'
1257
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1258
+ # will be added to the HTTP request.
1259
+ #
1260
+ # @return [PersistedFace] operation results.
1261
+ #
1262
+ def add_face_from_url(large_face_list_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1263
+ response = add_face_from_url_async(large_face_list_id, url, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
1264
+ response.body unless response.nil?
1265
+ end
1266
+
1267
+ #
1268
+ # Add a face to a specified large face list, up to 1,000,000 faces.
1269
+ # <br /> To deal with an image contains multiple faces, input face can be
1270
+ # specified as an image with a targetFace rectangle. It returns a
1271
+ # persistedFaceId representing the added face. No image will be stored. Only
1272
+ # the extracted face feature will be stored on server until [LargeFaceList Face
1273
+ # -
1274
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a158c8ad2de3616c086f2d4)
1275
+ # or [LargeFaceList -
1276
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
1277
+ # is called.
1278
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
1279
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
1280
+ # * Higher face image quality means better recognition precision. Please
1281
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
1282
+ # (100 pixels between eyes) or bigger.
1283
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
1284
+ # image file size is from 1KB to 6MB.
1285
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
1286
+ # be regarded as an error. If the provided "targetFace" rectangle is not
1287
+ # returned from [Face -
1288
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
1289
+ # there’s no guarantee to detect and add the face successfully.
1290
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
1291
+ # large occlusions will cause failures.
1292
+ # * Adding/deleting faces to/from a same face list are processed sequentially
1293
+ # and to/from different face lists are in parallel.
1294
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1295
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1296
+ # need a proportionally larger minimum face size.
1297
+ # * Different 'detectionModel' values can be provided. To use and compare
1298
+ # different detection models, please refer to [How to specify a detection
1299
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1300
+ # | Model | Recommended use-case(s) |
1301
+ # | ---------- | -------- |
1302
+ # | 'detection_01': | The default detection model for [LargeFaceList - Add
1303
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3).
1304
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1305
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1306
+ # faces in such cases may not be detected. |
1307
+ # | 'detection_02': | Detection model released in 2019 May with improved
1308
+ # accuracy especially on small, side and blurry faces. |
1309
+ #
1310
+ # Quota:
1311
+ # * Free-tier subscription quota: 1,000 faces per large face list.
1312
+ # * S0-tier subscription quota: 1,000,000 faces per large face list.
1313
+ #
1314
+ # @param large_face_list_id [String] Id referencing a particular large face
1315
+ # list.
1316
+ # @param url [String] Publicly reachable URL of an image
1317
+ # @param user_data [String] User-specified data about the face for any purpose.
1318
+ # The maximum length is 1KB.
1319
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1320
+ # face to be added to a person in the format of
1321
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1322
+ # is more than one face in the image, targetFace is required to specify which
1323
+ # face to add. No targetFace means there is only one face detected in the
1324
+ # entire image.
1325
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1326
+ # model is used to detect faces in the submitted image. A detection model name
1327
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1328
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1329
+ # another model is needed, please explicitly specify it. Possible values
1330
+ # include: 'detection_01', 'detection_02'
1331
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1332
+ # will be added to the HTTP request.
1333
+ #
1334
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1335
+ #
1336
+ def add_face_from_url_with_http_info(large_face_list_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1337
+ add_face_from_url_async(large_face_list_id, url, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
1338
+ end
1339
+
1340
+ #
1341
+ # Add a face to a specified large face list, up to 1,000,000 faces.
1342
+ # <br /> To deal with an image contains multiple faces, input face can be
1343
+ # specified as an image with a targetFace rectangle. It returns a
1344
+ # persistedFaceId representing the added face. No image will be stored. Only
1345
+ # the extracted face feature will be stored on server until [LargeFaceList Face
1346
+ # -
1347
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a158c8ad2de3616c086f2d4)
1348
+ # or [LargeFaceList -
1349
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
1350
+ # is called.
1351
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
1352
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
1353
+ # * Higher face image quality means better recognition precision. Please
1354
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
1355
+ # (100 pixels between eyes) or bigger.
1356
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
1357
+ # image file size is from 1KB to 6MB.
1358
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
1359
+ # be regarded as an error. If the provided "targetFace" rectangle is not
1360
+ # returned from [Face -
1361
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
1362
+ # there’s no guarantee to detect and add the face successfully.
1363
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
1364
+ # large occlusions will cause failures.
1365
+ # * Adding/deleting faces to/from a same face list are processed sequentially
1366
+ # and to/from different face lists are in parallel.
1367
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1368
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1369
+ # need a proportionally larger minimum face size.
1370
+ # * Different 'detectionModel' values can be provided. To use and compare
1371
+ # different detection models, please refer to [How to specify a detection
1372
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1373
+ # | Model | Recommended use-case(s) |
1374
+ # | ---------- | -------- |
1375
+ # | 'detection_01': | The default detection model for [LargeFaceList - Add
1376
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3).
1377
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1378
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1379
+ # faces in such cases may not be detected. |
1380
+ # | 'detection_02': | Detection model released in 2019 May with improved
1381
+ # accuracy especially on small, side and blurry faces. |
1382
+ #
1383
+ # Quota:
1384
+ # * Free-tier subscription quota: 1,000 faces per large face list.
1385
+ # * S0-tier subscription quota: 1,000,000 faces per large face list.
1386
+ #
1387
+ # @param large_face_list_id [String] Id referencing a particular large face
1388
+ # list.
1389
+ # @param url [String] Publicly reachable URL of an image
1390
+ # @param user_data [String] User-specified data about the face for any purpose.
1391
+ # The maximum length is 1KB.
1392
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1393
+ # face to be added to a person in the format of
1394
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1395
+ # is more than one face in the image, targetFace is required to specify which
1396
+ # face to add. No targetFace means there is only one face detected in the
1397
+ # entire image.
1398
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1399
+ # model is used to detect faces in the submitted image. A detection model name
1400
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1401
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1402
+ # another model is needed, please explicitly specify it. Possible values
1403
+ # include: 'detection_01', 'detection_02'
1404
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1405
+ # to the HTTP request.
1406
+ #
1407
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1408
+ #
1409
+ def add_face_from_url_async(large_face_list_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1410
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
1411
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
1412
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
1413
+ 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?
1414
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
1415
+ fail ArgumentError, 'url is nil' if url.nil?
1416
+
1417
+ image_url = ImageUrl.new
1418
+ unless url.nil?
1419
+ image_url.url = url
1420
+ end
1421
+
1422
+ request_headers = {}
1423
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1424
+
1425
+ # Set Headers
1426
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1427
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1428
+
1429
+ # Serialize Request
1430
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::ImageUrl.mapper()
1431
+ request_content = @client.serialize(request_mapper, image_url)
1432
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
1433
+
1434
+ path_template = 'largefacelists/{largeFaceListId}/persistedfaces'
1435
+
1436
+ request_url = @base_url || @client.base_url
1437
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
1438
+
1439
+ options = {
1440
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1441
+ path_params: {'largeFaceListId' => large_face_list_id},
1442
+ query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(','),'detectionModel' => detection_model},
1443
+ body: request_content,
1444
+ headers: request_headers.merge(custom_headers || {}),
1445
+ base_url: request_url
1446
+ }
1447
+ promise = @client.make_request_async(:post, path_template, options)
1448
+
1449
+ promise = promise.then do |result|
1450
+ http_response = result.response
1451
+ status_code = http_response.status
1452
+ response_content = http_response.body
1453
+ unless status_code == 200
1454
+ error_model = JSON.load(response_content)
1455
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1456
+ end
1457
+
1458
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1459
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1460
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1461
+ # Deserialize Response
1462
+ if status_code == 200
1463
+ begin
1464
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1465
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
1466
+ result.body = @client.deserialize(result_mapper, parsed_response)
1467
+ rescue Exception => e
1468
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1469
+ end
1470
+ end
1471
+
1472
+ result
1473
+ end
1474
+
1475
+ promise.execute
1476
+ end
1477
+
1478
+ #
1479
+ # List all faces in a large face list, and retrieve face information (including
1480
+ # userData and persistedFaceIds of registered faces of the face).
1481
+ #
1482
+ # @param large_face_list_id [String] Id referencing a particular large face
1483
+ # list.
1484
+ # @param start [String] Starting face id to return (used to list a range of
1485
+ # faces).
1486
+ # @param top [Integer] Number of faces to return starting with the face id
1487
+ # indicated by the 'start' parameter.
1488
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1489
+ # will be added to the HTTP request.
1490
+ #
1491
+ # @return [Array] operation results.
1492
+ #
1493
+ def list_faces(large_face_list_id, start:nil, top:nil, custom_headers:nil)
1494
+ response = list_faces_async(large_face_list_id, start:start, top:top, custom_headers:custom_headers).value!
1495
+ response.body unless response.nil?
1496
+ end
1497
+
1498
+ #
1499
+ # List all faces in a large face list, and retrieve face information (including
1500
+ # userData and persistedFaceIds of registered faces of the face).
1501
+ #
1502
+ # @param large_face_list_id [String] Id referencing a particular large face
1503
+ # list.
1504
+ # @param start [String] Starting face id to return (used to list a range of
1505
+ # faces).
1506
+ # @param top [Integer] Number of faces to return starting with the face id
1507
+ # indicated by the 'start' parameter.
1508
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1509
+ # will be added to the HTTP request.
1510
+ #
1511
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1512
+ #
1513
+ def list_faces_with_http_info(large_face_list_id, start:nil, top:nil, custom_headers:nil)
1514
+ list_faces_async(large_face_list_id, start:start, top:top, custom_headers:custom_headers).value!
1515
+ end
1516
+
1517
+ #
1518
+ # List all faces in a large face list, and retrieve face information (including
1519
+ # userData and persistedFaceIds of registered faces of the face).
1520
+ #
1521
+ # @param large_face_list_id [String] Id referencing a particular large face
1522
+ # list.
1523
+ # @param start [String] Starting face id to return (used to list a range of
1524
+ # faces).
1525
+ # @param top [Integer] Number of faces to return starting with the face id
1526
+ # indicated by the 'start' parameter.
1527
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1528
+ # to the HTTP request.
1529
+ #
1530
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1531
+ #
1532
+ def list_faces_async(large_face_list_id, start:nil, top:nil, custom_headers:nil)
1533
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
1534
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
1535
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
1536
+ 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?
1537
+ fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMaximum': '1000'" if !top.nil? && top > 1000
1538
+ fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMinimum': '1'" if !top.nil? && top < 1
1539
+
1540
+
1541
+ request_headers = {}
1542
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1543
+
1544
+ # Set Headers
1545
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1546
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1547
+ path_template = 'largefacelists/{largeFaceListId}/persistedfaces'
1548
+
1549
+ request_url = @base_url || @client.base_url
1550
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
1551
+
1552
+ options = {
1553
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1554
+ path_params: {'largeFaceListId' => large_face_list_id},
1555
+ query_params: {'start' => start,'top' => top},
1556
+ headers: request_headers.merge(custom_headers || {}),
1557
+ base_url: request_url
1558
+ }
1559
+ promise = @client.make_request_async(:get, path_template, options)
1560
+
1561
+ promise = promise.then do |result|
1562
+ http_response = result.response
1563
+ status_code = http_response.status
1564
+ response_content = http_response.body
1565
+ unless status_code == 200
1566
+ error_model = JSON.load(response_content)
1567
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1568
+ end
1569
+
1570
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1571
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1572
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1573
+ # Deserialize Response
1574
+ if status_code == 200
1575
+ begin
1576
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1577
+ result_mapper = {
1578
+ client_side_validation: true,
1579
+ required: false,
1580
+ serialized_name: 'parsed_response',
1581
+ type: {
1582
+ name: 'Sequence',
1583
+ element: {
1584
+ client_side_validation: true,
1585
+ required: false,
1586
+ serialized_name: 'PersistedFaceElementType',
1587
+ type: {
1588
+ name: 'Composite',
1589
+ class_name: 'PersistedFace'
1590
+ }
1591
+ }
1592
+ }
1593
+ }
1594
+ result.body = @client.deserialize(result_mapper, parsed_response)
1595
+ rescue Exception => e
1596
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1597
+ end
1598
+ end
1599
+
1600
+ result
1601
+ end
1602
+
1603
+ promise.execute
1604
+ end
1605
+
1606
+ #
1607
+ # Add a face to a specified large face list, up to 1,000,000 faces.
1608
+ # <br /> To deal with an image contains multiple faces, input face can be
1609
+ # specified as an image with a targetFace rectangle. It returns a
1610
+ # persistedFaceId representing the added face. No image will be stored. Only
1611
+ # the extracted face feature will be stored on server until [LargeFaceList Face
1612
+ # -
1613
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a158c8ad2de3616c086f2d4)
1614
+ # or [LargeFaceList -
1615
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
1616
+ # is called.
1617
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
1618
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
1619
+ # * Higher face image quality means better recognition precision. Please
1620
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
1621
+ # (100 pixels between eyes) or bigger.
1622
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
1623
+ # image file size is from 1KB to 6MB.
1624
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
1625
+ # be regarded as an error. If the provided "targetFace" rectangle is not
1626
+ # returned from [Face -
1627
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
1628
+ # there’s no guarantee to detect and add the face successfully.
1629
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
1630
+ # large occlusions will cause failures.
1631
+ # * Adding/deleting faces to/from a same face list are processed sequentially
1632
+ # and to/from different face lists are in parallel.
1633
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1634
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1635
+ # need a proportionally larger minimum face size.
1636
+ # * Different 'detectionModel' values can be provided. To use and compare
1637
+ # different detection models, please refer to [How to specify a detection
1638
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1639
+ # | Model | Recommended use-case(s) |
1640
+ # | ---------- | -------- |
1641
+ # | 'detection_01': | The default detection model for [LargeFaceList - Add
1642
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3).
1643
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1644
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1645
+ # faces in such cases may not be detected. |
1646
+ # | 'detection_02': | Detection model released in 2019 May with improved
1647
+ # accuracy especially on small, side and blurry faces. |
1648
+ #
1649
+ # Quota:
1650
+ # * Free-tier subscription quota: 1,000 faces per large face list.
1651
+ # * S0-tier subscription quota: 1,000,000 faces per large face list.
1652
+ #
1653
+ # @param large_face_list_id [String] Id referencing a particular large face
1654
+ # list.
1655
+ # @param image An image stream.
1656
+ # @param user_data [String] User-specified data about the face for any purpose.
1657
+ # The maximum length is 1KB.
1658
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1659
+ # face to be added to a person in the format of
1660
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1661
+ # is more than one face in the image, targetFace is required to specify which
1662
+ # face to add. No targetFace means there is only one face detected in the
1663
+ # entire image.
1664
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1665
+ # model is used to detect faces in the submitted image. A detection model name
1666
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1667
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1668
+ # another model is needed, please explicitly specify it. Possible values
1669
+ # include: 'detection_01', 'detection_02'
1670
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1671
+ # will be added to the HTTP request.
1672
+ #
1673
+ # @return [PersistedFace] operation results.
1674
+ #
1675
+ def add_face_from_stream(large_face_list_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1676
+ response = add_face_from_stream_async(large_face_list_id, image, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
1677
+ response.body unless response.nil?
1678
+ end
1679
+
1680
+ #
1681
+ # Add a face to a specified large face list, up to 1,000,000 faces.
1682
+ # <br /> To deal with an image contains multiple faces, input face can be
1683
+ # specified as an image with a targetFace rectangle. It returns a
1684
+ # persistedFaceId representing the added face. No image will be stored. Only
1685
+ # the extracted face feature will be stored on server until [LargeFaceList Face
1686
+ # -
1687
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a158c8ad2de3616c086f2d4)
1688
+ # or [LargeFaceList -
1689
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
1690
+ # is called.
1691
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
1692
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
1693
+ # * Higher face image quality means better recognition precision. Please
1694
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
1695
+ # (100 pixels between eyes) or bigger.
1696
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
1697
+ # image file size is from 1KB to 6MB.
1698
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
1699
+ # be regarded as an error. If the provided "targetFace" rectangle is not
1700
+ # returned from [Face -
1701
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
1702
+ # there’s no guarantee to detect and add the face successfully.
1703
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
1704
+ # large occlusions will cause failures.
1705
+ # * Adding/deleting faces to/from a same face list are processed sequentially
1706
+ # and to/from different face lists are in parallel.
1707
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1708
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1709
+ # need a proportionally larger minimum face size.
1710
+ # * Different 'detectionModel' values can be provided. To use and compare
1711
+ # different detection models, please refer to [How to specify a detection
1712
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1713
+ # | Model | Recommended use-case(s) |
1714
+ # | ---------- | -------- |
1715
+ # | 'detection_01': | The default detection model for [LargeFaceList - Add
1716
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3).
1717
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1718
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1719
+ # faces in such cases may not be detected. |
1720
+ # | 'detection_02': | Detection model released in 2019 May with improved
1721
+ # accuracy especially on small, side and blurry faces. |
1722
+ #
1723
+ # Quota:
1724
+ # * Free-tier subscription quota: 1,000 faces per large face list.
1725
+ # * S0-tier subscription quota: 1,000,000 faces per large face list.
1726
+ #
1727
+ # @param large_face_list_id [String] Id referencing a particular large face
1728
+ # list.
1729
+ # @param image An image stream.
1730
+ # @param user_data [String] User-specified data about the face for any purpose.
1731
+ # The maximum length is 1KB.
1732
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1733
+ # face to be added to a person in the format of
1734
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1735
+ # is more than one face in the image, targetFace is required to specify which
1736
+ # face to add. No targetFace means there is only one face detected in the
1737
+ # entire image.
1738
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1739
+ # model is used to detect faces in the submitted image. A detection model name
1740
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1741
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1742
+ # another model is needed, please explicitly specify it. Possible values
1743
+ # include: 'detection_01', 'detection_02'
1744
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1745
+ # will be added to the HTTP request.
1746
+ #
1747
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1748
+ #
1749
+ def add_face_from_stream_with_http_info(large_face_list_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1750
+ add_face_from_stream_async(large_face_list_id, image, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
1751
+ end
1752
+
1753
+ #
1754
+ # Add a face to a specified large face list, up to 1,000,000 faces.
1755
+ # <br /> To deal with an image contains multiple faces, input face can be
1756
+ # specified as an image with a targetFace rectangle. It returns a
1757
+ # persistedFaceId representing the added face. No image will be stored. Only
1758
+ # the extracted face feature will be stored on server until [LargeFaceList Face
1759
+ # -
1760
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a158c8ad2de3616c086f2d4)
1761
+ # or [LargeFaceList -
1762
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/5a1580d5d2de3616c086f2cd)
1763
+ # is called.
1764
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
1765
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
1766
+ # * Higher face image quality means better recognition precision. Please
1767
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
1768
+ # (100 pixels between eyes) or bigger.
1769
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
1770
+ # image file size is from 1KB to 6MB.
1771
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
1772
+ # be regarded as an error. If the provided "targetFace" rectangle is not
1773
+ # returned from [Face -
1774
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
1775
+ # there’s no guarantee to detect and add the face successfully.
1776
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
1777
+ # large occlusions will cause failures.
1778
+ # * Adding/deleting faces to/from a same face list are processed sequentially
1779
+ # and to/from different face lists are in parallel.
1780
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1781
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1782
+ # need a proportionally larger minimum face size.
1783
+ # * Different 'detectionModel' values can be provided. To use and compare
1784
+ # different detection models, please refer to [How to specify a detection
1785
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1786
+ # | Model | Recommended use-case(s) |
1787
+ # | ---------- | -------- |
1788
+ # | 'detection_01': | The default detection model for [LargeFaceList - Add
1789
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/5a158c10d2de3616c086f2d3).
1790
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1791
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1792
+ # faces in such cases may not be detected. |
1793
+ # | 'detection_02': | Detection model released in 2019 May with improved
1794
+ # accuracy especially on small, side and blurry faces. |
1795
+ #
1796
+ # Quota:
1797
+ # * Free-tier subscription quota: 1,000 faces per large face list.
1798
+ # * S0-tier subscription quota: 1,000,000 faces per large face list.
1799
+ #
1800
+ # @param large_face_list_id [String] Id referencing a particular large face
1801
+ # list.
1802
+ # @param image An image stream.
1803
+ # @param user_data [String] User-specified data about the face for any purpose.
1804
+ # The maximum length is 1KB.
1805
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1806
+ # face to be added to a person in the format of
1807
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1808
+ # is more than one face in the image, targetFace is required to specify which
1809
+ # face to add. No targetFace means there is only one face detected in the
1810
+ # entire image.
1811
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1812
+ # model is used to detect faces in the submitted image. A detection model name
1813
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1814
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1815
+ # another model is needed, please explicitly specify it. Possible values
1816
+ # include: 'detection_01', 'detection_02'
1817
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1818
+ # to the HTTP request.
1819
+ #
1820
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1821
+ #
1822
+ def add_face_from_stream_async(large_face_list_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1823
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
1824
+ fail ArgumentError, 'large_face_list_id is nil' if large_face_list_id.nil?
1825
+ fail ArgumentError, "'large_face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !large_face_list_id.nil? && large_face_list_id.length > 64
1826
+ 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?
1827
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
1828
+ fail ArgumentError, 'image is nil' if image.nil?
1829
+
1830
+
1831
+ request_headers = {}
1832
+ request_headers['Content-Type'] = 'application/octet-stream'
1833
+
1834
+ # Set Headers
1835
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1836
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1837
+
1838
+ # Serialize Request
1839
+ request_mapper = {
1840
+ client_side_validation: true,
1841
+ required: true,
1842
+ serialized_name: 'Image',
1843
+ type: {
1844
+ name: 'Stream'
1845
+ }
1846
+ }
1847
+ request_content = @client.serialize(request_mapper, image)
1848
+
1849
+ path_template = 'largefacelists/{largeFaceListId}/persistedfaces'
1850
+
1851
+ request_url = @base_url || @client.base_url
1852
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
1853
+
1854
+ options = {
1855
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1856
+ path_params: {'largeFaceListId' => large_face_list_id},
1857
+ query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(','),'detectionModel' => detection_model},
1858
+ body: request_content,
1859
+ headers: request_headers.merge(custom_headers || {}),
1860
+ base_url: request_url
1861
+ }
1862
+ promise = @client.make_request_async(:post, path_template, options)
1863
+
1864
+ promise = promise.then do |result|
1865
+ http_response = result.response
1866
+ status_code = http_response.status
1867
+ response_content = http_response.body
1868
+ unless status_code == 200
1869
+ error_model = JSON.load(response_content)
1870
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1871
+ end
1872
+
1873
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1874
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1875
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1876
+ # Deserialize Response
1877
+ if status_code == 200
1878
+ begin
1879
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1880
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
1881
+ result.body = @client.deserialize(result_mapper, parsed_response)
1882
+ rescue Exception => e
1883
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1884
+ end
1885
+ end
1886
+
1887
+ result
1888
+ end
1889
+
1890
+ promise.execute
1891
+ end
1892
+
1893
+ end
1894
+ end