-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
FaceOperationsExtensions.cs
514 lines (505 loc) · 32.4 KB
/
FaceOperationsExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
// <auto-generated>
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Microsoft.Azure.CognitiveServices.Vision.Face
{
using Models;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// Extension methods for FaceOperations.
/// </summary>
public static partial class FaceOperationsExtensions
{
/// <summary>
/// Given query face's faceId, to search the similar-looking faces from a
/// faceId array, a face list or a large face list. faceId array contains the
/// faces created by [Face - Detect With
/// Url](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl) or
/// [Face - Detect With
/// Stream](https://docs.microsoft.com/rest/api/faceapi/face/detectwithstream),
/// which will expire at the time specified by faceIdTimeToLive after creation.
/// A "faceListId" is created by [FaceList -
/// Create](https://docs.microsoft.com/rest/api/faceapi/facelist/create)
/// containing persistedFaceIds that will not expire. And a "largeFaceListId"
/// is created by [LargeFaceList -
/// Create](https://docs.microsoft.com/rest/api/faceapi/largefacelist/create)
/// containing persistedFaceIds that will also not expire. Depending on the
/// input the returned similar faces list contains faceIds or persistedFaceIds
/// ranked by similarity.
/// <br/>Find similar has two working modes, "matchPerson" and
/// "matchFace". "matchPerson" is the default mode that it tries to find faces
/// of the same person as possible by using internal same-person thresholds. It
/// is useful to find a known person's other photos. Note that an empty list
/// will be returned if no faces pass the internal thresholds. "matchFace" mode
/// ignores same-person thresholds and returns ranked similar faces anyway,
/// even the similarity is low. It can be used in the cases like searching
/// celebrity-looking faces.
/// <br/>The 'recognitionModel' associated with the query face's faceId
/// should be the same as the 'recognitionModel' used by the target faceId
/// array, face list or large face list.
///
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='faceId'>
/// FaceId of the query face. User needs to call Face - Detect first to get a
/// valid faceId. Note that this faceId is not persisted and will expire at the
/// time specified by faceIdTimeToLive after the detection call
/// </param>
/// <param name='faceListId'>
/// An existing user-specified unique candidate face list, created in Face List
/// - Create a Face List. Face list contains a set of persistedFaceIds which
/// are persisted and will never expire. Parameter faceListId, largeFaceListId
/// and faceIds should not be provided at the same time.
/// </param>
/// <param name='largeFaceListId'>
/// An existing user-specified unique candidate large face list, created in
/// LargeFaceList - Create. Large face list contains a set of persistedFaceIds
/// which are persisted and will never expire. Parameter faceListId,
/// largeFaceListId and faceIds should not be provided at the same time.
/// </param>
/// <param name='faceIds'>
/// An array of candidate faceIds. All of them are created by Face - Detect and
/// the faceIds will expire at the time specified by faceIdTimeToLive after the
/// detection call. The number of faceIds is limited to 1000. Parameter
/// faceListId, largeFaceListId and faceIds should not be provided at the same
/// time.
/// </param>
/// <param name='maxNumOfCandidatesReturned'>
/// The number of top similar faces returned. The valid range is [1, 1000].
/// </param>
/// <param name='mode'>
/// Similar face searching mode. It can be "matchPerson" or "matchFace".
/// Possible values include: 'matchPerson', 'matchFace'
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<SimilarFace>> FindSimilarAsync(this IFaceOperations operations, System.Guid faceId, string faceListId = default(string), string largeFaceListId = default(string), IList<System.Guid?> faceIds = default(IList<System.Guid?>), int? maxNumOfCandidatesReturned = 20, FindSimilarMatchMode mode = default(FindSimilarMatchMode), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.FindSimilarWithHttpMessagesAsync(faceId, faceListId, largeFaceListId, faceIds, maxNumOfCandidatesReturned, mode, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Divide candidate faces into groups based on face similarity.<br />
/// * The output is one or more disjointed face groups and a messyGroup. A face
/// group contains faces that have similar looking, often of the same person.
/// Face groups are ranked by group size, i.e. number of faces. Notice that
/// faces belonging to a same person might be split into several groups in the
/// result.
/// * MessyGroup is a special face group containing faces that cannot find any
/// similar counterpart face from original faces. The messyGroup will not
/// appear in the result if all faces found their counterparts.
/// * Group API needs at least 2 candidate faces and 1000 at most. We suggest
/// to try [Face -
/// Verify](https://docs.microsoft.com/rest/api/faceapi/face/verifyfacetoface)
/// when you only have 2 candidate faces.
/// * The 'recognitionModel' associated with the query faces' faceIds should be
/// the same.
///
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='faceIds'>
/// Array of candidate faceId created by Face - Detect. The maximum is 1000
/// faces
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<GroupResult> GroupAsync(this IFaceOperations operations, IList<System.Guid> faceIds, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.GroupWithHttpMessagesAsync(faceIds, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// 1-to-many identification to find the closest matches of the specific query
/// person face from a person group, large person group, person directory
/// dynamic person group or person directory personIds array.
/// <br/> For each face in the faceIds array, Face Identify will compute
/// similarities between the query face and all the faces in the person group
/// (given by personGroupId) or large person group (given by
/// largePersonGroupId), and return candidate person(s) for that face ranked by
/// similarity confidence. The person group/large person group should be
/// trained to make it ready for identification. See more in [PersonGroup -
/// Train](https://docs.microsoft.com/rest/api/faceapi/persongroup/train) and
/// [LargePersonGroup -
/// Train](https://docs.microsoft.com/rest/api/faceapi/largepersongroup/train).
/// <br/>
///
/// Remarks:<br />
/// * The algorithm allows more than one face to be identified independently at
/// the same request, but no more than 10 faces.
/// * Each person in the person group/large person group could have more than
/// one face, but no more than 248 faces.
/// * Higher face image quality means better identification precision. Please
/// consider high-quality faces: frontal, clear, and face size is 200x200
/// pixels (100 pixels between eyes) or bigger.
/// * Number of candidates returned is restricted by maxNumOfCandidatesReturned
/// and confidenceThreshold. If no person is identified, the returned
/// candidates will be an empty array.
/// * Try [Face - Find
/// Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar) when
/// you need to find similar faces from a face list/large face list instead of
/// a person group/large person group.
/// * The 'recognitionModel' associated with the query faces' faceIds should be
/// the same as the 'recognitionModel' used by the target person group or large
/// person group.
///
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='faceIds'>
/// Array of query faces faceIds, created by the Face - Detect. Each of the
/// faces are identified independently. The valid number of faceIds is between
/// [1, 10].
/// </param>
/// <param name='personGroupId'>
/// PersonGroupId of the target person group, created by PersonGroup - Create.
/// Parameter personGroupId, largePersonGroupId, dynamicPersonGroupId, or
/// personIds should not be provided at the same time.
/// </param>
/// <param name='largePersonGroupId'>
/// LargePersonGroupId of the target large person group, created by
/// LargePersonGroup - Create. Parameter personGroupId, largePersonGroupId,
/// dynamicPersonGroupId, or personIds should not be provided at the same time.
/// </param>
/// <param name='dynamicPersonGroupId'>
/// DynamicPersonGroupId of the target PersonDirectory dynamic person group to
/// match against. Parameter personGroupId, largePersonGroupId,
/// dynamicPersonGroupId, or personIds should not be provided at the same time.
/// </param>
/// <param name='personIds'>
/// Array of personIds created in PersonDirectory - PersonCreate. The valid
/// number of personIds is between [1,30]. Providing a single '*' in the array
/// identifies against all persons inside the PersonDirectory. Parameter
/// personGroupId, largePersonGroupId, dynamicPersonGroupId, or personIds
/// should not be provided at the same time.
/// </param>
/// <param name='maxNumOfCandidatesReturned'>
/// The range of maxNumOfCandidatesReturned is between 1 and 100 (default is
/// 1).
/// </param>
/// <param name='confidenceThreshold'>
/// Confidence threshold of identification, used to judge whether one face
/// belong to one person. The range of confidenceThreshold is [0, 1] (default
/// specified by algorithm).
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<IdentifyResult>> IdentifyAsync(this IFaceOperations operations, IList<System.Guid> faceIds, string personGroupId = default(string), string largePersonGroupId = default(string), string dynamicPersonGroupId = default(string), IList<string> personIds = default(IList<string>), int? maxNumOfCandidatesReturned = 1, double? confidenceThreshold = default(double?), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.IdentifyWithHttpMessagesAsync(faceIds, personGroupId, largePersonGroupId, dynamicPersonGroupId, personIds, maxNumOfCandidatesReturned, confidenceThreshold, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Verify whether two faces belong to a same person or whether one face
/// belongs to a person.
/// <br/>
/// Remarks:<br />
/// * Higher face image quality means better identification precision. Please
/// consider high-quality faces: frontal, clear, and face size is 200x200
/// pixels (100 pixels between eyes) or bigger.
/// * For the scenarios that are sensitive to accuracy please make your own
/// judgment.
/// * The 'recognitionModel' associated with the query faces' faceIds should be
/// the same as the 'recognitionModel' used by the target face, person group or
/// large person group.
///
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='faceId1'>
/// FaceId of the first face, comes from Face - Detect
/// </param>
/// <param name='faceId2'>
/// FaceId of the second face, comes from Face - Detect
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<VerifyResult> VerifyFaceToFaceAsync(this IFaceOperations operations, System.Guid faceId1, System.Guid faceId2, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.VerifyFaceToFaceWithHttpMessagesAsync(faceId1, faceId2, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Detect human faces in an image, return face rectangles, and optionally with
/// faceIds, landmarks, and attributes.<br />
/// * No image will be stored. Only the extracted face feature will be stored
/// on server. The faceId is an identifier of the face feature and will be used
/// in [Face -
/// Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify), [Face
/// -
/// Verify](https://docs.microsoft.com/rest/api/faceapi/face/verifyfacetoface),
/// and [Face - Find
/// Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar). The
/// stored face feature(s) will expire and be deleted at the time specified by
/// faceIdTimeToLive after the original detection call.
/// * Optional parameters include faceId, landmarks, and attributes. Attributes
/// include age, gender, headPose, smile, facialHair, glasses, emotion, hair,
/// makeup, occlusion, accessories, blur, exposure, noise, mask, and
/// qualityForRecognition. Some of the results returned for specific attributes
/// may not be highly accurate.
/// * JPEG, PNG, GIF (the first frame), and BMP format are supported. The
/// allowed image file size is from 1KB to 6MB.
/// * Up to 100 faces can be returned for an image. Faces are ranked by face
/// rectangle size from large to small.
/// * For optimal results when querying [Face -
/// Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify), [Face
/// -
/// Verify](https://docs.microsoft.com/rest/api/faceapi/face/verifyfacetoface),
/// and [Face - Find
/// Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar)
/// ('returnFaceId' is true), please use faces that are: frontal, clear, and
/// with a minimum size of 200x200 pixels (100 pixels between eyes).
/// * The minimum detectable face size is 36x36 pixels in an image no larger
/// than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels
/// will need a proportionally larger minimum face size.
/// * Different 'detectionModel' values can be provided. To use and compare
/// different detection models, please refer to [How to specify a detection
/// model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model).
///
/// * Different 'recognitionModel' values are provided. If follow-up operations
/// like Verify, Identify, Find Similar are needed, please specify the
/// recognition model with 'recognitionModel' parameter. The default value for
/// 'recognitionModel' is 'recognition_01', if latest model needed, please
/// explicitly specify the model you need in this parameter. Once specified,
/// the detected faceIds will be associated with the specified recognition
/// model. More details, please refer to [Specify a recognition
/// model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-recognition-model).
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='url'>
/// Publicly reachable URL of an image
/// </param>
/// <param name='returnFaceId'>
/// A value indicating whether the operation should return faceIds of detected
/// faces. Detecting with this value set to true requires additional access
/// approvals at https://aka.ms/facerecognition.
/// </param>
/// <param name='returnFaceLandmarks'>
/// A value indicating whether the operation should return landmarks of the
/// detected faces.
/// </param>
/// <param name='returnFaceAttributes'>
/// Analyze and return the one or more specified face attributes in the
/// comma-separated string like "returnFaceAttributes=age,gender". The
/// available attributes depends on the 'detectionModel' specified.
/// 'detection_01' supports age, gender, headPose, smile, facialHair, glasses,
/// emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, and
/// qualityForRecognition. While 'detection_02' does not support any attributes
/// and 'detection_03' only supports mask and qualityForRecognition.
/// Additionally, qualityForRecognition is only supported when the
/// 'recognitionModel' is specified as 'recognition_03' or 'recognition_04'.
/// Note that each face attribute analysis has additional computational and
/// time cost.
/// </param>
/// <param name='recognitionModel'>
/// Name of recognition model. Recognition model is used when the face features
/// are extracted and associated with detected faceIds, (Large)FaceList or
/// (Large)PersonGroup. A recognition model name can be provided when
/// performing Face - Detect or (Large)FaceList - Create or (Large)PersonGroup
/// - Create. The default value is 'recognition_01', if latest model needed,
/// please explicitly specify the model you need. Possible values include:
/// 'recognition_01', 'recognition_02', 'recognition_03', 'recognition_04'
/// </param>
/// <param name='returnRecognitionModel'>
/// A value indicating whether the operation should return 'recognitionModel'
/// in response.
/// </param>
/// <param name='detectionModel'>
/// Name of detection model. Detection model is used to detect faces in the
/// submitted image. A detection model name can be provided when performing
/// Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add
/// Face. The default value is 'detection_01', if another model is needed,
/// please explicitly specify it. Possible values include: 'detection_01',
/// 'detection_02', 'detection_03'
/// </param>
/// <param name='faceIdTimeToLive'>
/// The number of seconds for the faceId being cached. Supported range from 60
/// seconds up to 86400 seconds. The default value is 86400 (24 hours).
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<DetectedFace>> DetectWithUrlAsync(this IFaceOperations operations, string url, bool? returnFaceId = default(bool?), bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), string recognitionModel = default(string), bool? returnRecognitionModel = false, string detectionModel = default(string), int? faceIdTimeToLive = 86400, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.DetectWithUrlWithHttpMessagesAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes, recognitionModel, returnRecognitionModel, detectionModel, faceIdTimeToLive, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Verify whether two faces belong to a same person. Compares a face Id with a
/// Person Id
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='faceId'>
/// FaceId of the face, comes from Face - Detect
/// </param>
/// <param name='personId'>
/// Specify a certain person in a person group, a large person group, or person
/// directory (if personGroupId and largePersonGroupId are omitted). personId
/// is created in PersonGroup Person - Create or LargePersonGroup Person -
/// Create or PersonDirectory - Create.
/// </param>
/// <param name='personGroupId'>
/// Using existing personGroupId and personId for fast loading a specified
/// person. personGroupId is created in PersonGroup - Create. Parameter
/// personGroupId and largePersonGroupId should not be provided at the same
/// time.
/// </param>
/// <param name='largePersonGroupId'>
/// Using existing largePersonGroupId and personId for fast loading a specified
/// person. largePersonGroupId is created in LargePersonGroup - Create.
/// Parameter personGroupId and largePersonGroupId should not be provided at
/// the same time.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<VerifyResult> VerifyFaceToPersonAsync(this IFaceOperations operations, System.Guid faceId, System.Guid personId, string personGroupId = default(string), string largePersonGroupId = default(string), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.VerifyFaceToPersonWithHttpMessagesAsync(faceId, personId, personGroupId, largePersonGroupId, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Detect human faces in an image, return face rectangles, and optionally with
/// faceIds, landmarks, and attributes.<br />
/// * No image will be stored. Only the extracted face feature will be stored
/// on server. The faceId is an identifier of the face feature and will be used
/// in [Face -
/// Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify), [Face
/// -
/// Verify](https://docs.microsoft.com/rest/api/faceapi/face/verifyfacetoface),
/// and [Face - Find
/// Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar). The
/// stored face feature(s) will expire and be deleted at the time specified by
/// faceIdTimeToLive after the original detection call.
/// * Optional parameters include faceId, landmarks, and attributes. Attributes
/// include age, gender, headPose, smile, facialHair, glasses, emotion, hair,
/// makeup, occlusion, accessories, blur, exposure, noise, mask, and
/// qualityForRecognition. Some of the results returned for specific attributes
/// may not be highly accurate.
/// * JPEG, PNG, GIF (the first frame), and BMP format are supported. The
/// allowed image file size is from 1KB to 6MB.
/// * Up to 100 faces can be returned for an image. Faces are ranked by face
/// rectangle size from large to small.
/// * For optimal results when querying [Face -
/// Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify), [Face
/// -
/// Verify](https://docs.microsoft.com/rest/api/faceapi/face/verifyfacetoface),
/// and [Face - Find
/// Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar)
/// ('returnFaceId' is true), please use faces that are: frontal, clear, and
/// with a minimum size of 200x200 pixels (100 pixels between eyes).
/// * The minimum detectable face size is 36x36 pixels in an image no larger
/// than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels
/// will need a proportionally larger minimum face size.
/// * Different 'detectionModel' values can be provided. To use and compare
/// different detection models, please refer to [How to specify a detection
/// model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
/// * Different 'recognitionModel' values are provided. If follow-up operations
/// like Verify, Identify, Find Similar are needed, please specify the
/// recognition model with 'recognitionModel' parameter. The default value for
/// 'recognitionModel' is 'recognition_01', if latest model needed, please
/// explicitly specify the model you need in this parameter. Once specified,
/// the detected faceIds will be associated with the specified recognition
/// model. More details, please refer to [Specify a recognition
/// model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-recognition-model).
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='image'>
/// An image stream.
/// </param>
/// <param name='returnFaceId'>
/// A value indicating whether the operation should return faceIds of detected
/// faces. Detecting with this value set to true requires additional access
/// approvals at https://aka.ms/facerecognition.
/// </param>
/// <param name='returnFaceLandmarks'>
/// A value indicating whether the operation should return landmarks of the
/// detected faces.
/// </param>
/// <param name='returnFaceAttributes'>
/// Analyze and return the one or more specified face attributes in the
/// comma-separated string like "returnFaceAttributes=age,gender". The
/// available attributes depends on the 'detectionModel' specified.
/// 'detection_01' supports age, gender, headPose, smile, facialHair, glasses,
/// emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, and
/// qualityForRecognition. While 'detection_02' does not support any attributes
/// and 'detection_03' only supports mask and qualityForRecognition.
/// Additionally, qualityForRecognition is only supported when the
/// 'recognitionModel' is specified as 'recognition_03' or 'recognition_04'.
/// Note that each face attribute analysis has additional computational and
/// time cost.
/// </param>
/// <param name='recognitionModel'>
/// Name of recognition model. Recognition model is used when the face features
/// are extracted and associated with detected faceIds, (Large)FaceList or
/// (Large)PersonGroup. A recognition model name can be provided when
/// performing Face - Detect or (Large)FaceList - Create or (Large)PersonGroup
/// - Create. The default value is 'recognition_01', if latest model needed,
/// please explicitly specify the model you need. Possible values include:
/// 'recognition_01', 'recognition_02', 'recognition_03', 'recognition_04'
/// </param>
/// <param name='returnRecognitionModel'>
/// A value indicating whether the operation should return 'recognitionModel'
/// in response.
/// </param>
/// <param name='detectionModel'>
/// Name of detection model. Detection model is used to detect faces in the
/// submitted image. A detection model name can be provided when performing
/// Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add
/// Face. The default value is 'detection_01', if another model is needed,
/// please explicitly specify it. Possible values include: 'detection_01',
/// 'detection_02', 'detection_03'
/// </param>
/// <param name='faceIdTimeToLive'>
/// The number of seconds for the faceId being cached. Supported range from 60
/// seconds up to 86400 seconds. The default value is 86400 (24 hours).
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<DetectedFace>> DetectWithStreamAsync(this IFaceOperations operations, Stream image, bool? returnFaceId = default(bool?), bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), string recognitionModel = default(string), bool? returnRecognitionModel = false, string detectionModel = default(string), int? faceIdTimeToLive = 86400, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.DetectWithStreamWithHttpMessagesAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes, recognitionModel, returnRecognitionModel, detectionModel, faceIdTimeToLive, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
}
}