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