| | 1 | | // <auto-generated> |
| | 2 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 3 | | // Licensed under the MIT License. See License.txt in the project root for |
| | 4 | | // license information. |
| | 5 | | // |
| | 6 | | // Code generated by Microsoft (R) AutoRest Code Generator. |
| | 7 | | // Changes may cause incorrect behavior and will be lost if the code is |
| | 8 | | // regenerated. |
| | 9 | | // </auto-generated> |
| | 10 | |
|
| | 11 | | namespace Microsoft.Azure.CognitiveServices.Vision.Face |
| | 12 | | { |
| | 13 | | using Models; |
| | 14 | | using System.Collections; |
| | 15 | | using System.Collections.Generic; |
| | 16 | | using System.IO; |
| | 17 | | using System.Threading; |
| | 18 | | using System.Threading.Tasks; |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Extension methods for FaceListOperations. |
| | 22 | | /// </summary> |
| | 23 | | public static partial class FaceListOperationsExtensions |
| | 24 | | { |
| | 25 | | /// <summary> |
| | 26 | | /// Create an empty face list with user-specified faceListId, name, an optional |
| | 27 | | /// userData and recognitionModel. Up to 64 face lists are allowed in one |
| | 28 | | /// subscription. |
| | 29 | | /// <br /> Face list is a list of faces, up to 1,000 faces, and used by |
| | 30 | | /// [Face - Find |
| | 31 | | /// Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237). |
| | 32 | | /// <br /> After creation, user should use [FaceList - Add |
| | 33 | | /// Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250) |
| | 34 | | /// to import the faces. No image will be stored. Only the extracted face |
| | 35 | | /// features are stored on server until [FaceList - |
| | 36 | | /// Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) |
| | 37 | | /// is called. |
| | 38 | | /// <br /> Find Similar is used for scenario like finding celebrity-like |
| | 39 | | /// faces, similar face filtering, or as a light way face identification. But |
| | 40 | | /// if the actual use is to identify person, please use |
| | 41 | | /// [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244) |
| | 42 | | /// / |
| | 43 | | /// [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d) |
| | 44 | | /// and [Face - |
| | 45 | | /// Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239). |
| | 46 | | /// <br /> Please consider |
| | 47 | | /// [LargeFaceList](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc) |
| | 48 | | /// when the face number is large. It can support up to 1,000,000 faces. |
| | 49 | | /// <br />'recognitionModel' should be specified to associate with this |
| | 50 | | /// face list. The default value for 'recognitionModel' is 'recognition_01', if |
| | 51 | | /// the latest model needed, please explicitly specify the model you need in |
| | 52 | | /// this parameter. New faces that are added to an existing face list will use |
| | 53 | | /// the recognition model that's already associated with the collection. |
| | 54 | | /// Existing face features in a face list can't be updated to features |
| | 55 | | /// extracted by another version of recognition model. |
| | 56 | | /// * 'recognition_01': The default recognition model for [FaceList- |
| | 57 | | /// Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524b). |
| | 58 | | /// All those face lists created before 2019 March are bonded with this |
| | 59 | | /// recognition model. |
| | 60 | | /// * 'recognition_02': Recognition model released in 2019 March. |
| | 61 | | /// 'recognition_02' is recommended since its overall accuracy is improved |
| | 62 | | /// compared with 'recognition_01'. |
| | 63 | | /// </summary> |
| | 64 | | /// <param name='operations'> |
| | 65 | | /// The operations group for this extension method. |
| | 66 | | /// </param> |
| | 67 | | /// <param name='faceListId'> |
| | 68 | | /// Id referencing a particular face list. |
| | 69 | | /// </param> |
| | 70 | | /// <param name='name'> |
| | 71 | | /// User defined name, maximum length is 128. |
| | 72 | | /// </param> |
| | 73 | | /// <param name='userData'> |
| | 74 | | /// User specified data. Length should not exceed 16KB. |
| | 75 | | /// </param> |
| | 76 | | /// <param name='recognitionModel'> |
| | 77 | | /// Possible values include: 'recognition_01', 'recognition_02' |
| | 78 | | /// </param> |
| | 79 | | /// <param name='cancellationToken'> |
| | 80 | | /// The cancellation token. |
| | 81 | | /// </param> |
| | 82 | | public static async Task CreateAsync(this IFaceListOperations operations, string faceListId, string name = d |
| | 83 | | { |
| 4 | 84 | | (await operations.CreateWithHttpMessagesAsync(faceListId, name, userData, recognitionModel, null, cancel |
| 4 | 85 | | } |
| | 86 | |
|
| | 87 | | /// <summary> |
| | 88 | | /// Retrieve a face list’s faceListId, name, userData, recognitionModel and |
| | 89 | | /// faces in the face list. |
| | 90 | | /// |
| | 91 | | /// </summary> |
| | 92 | | /// <param name='operations'> |
| | 93 | | /// The operations group for this extension method. |
| | 94 | | /// </param> |
| | 95 | | /// <param name='faceListId'> |
| | 96 | | /// Id referencing a particular face list. |
| | 97 | | /// </param> |
| | 98 | | /// <param name='returnRecognitionModel'> |
| | 99 | | /// A value indicating whether the operation should return 'recognitionModel' |
| | 100 | | /// in response. |
| | 101 | | /// </param> |
| | 102 | | /// <param name='cancellationToken'> |
| | 103 | | /// The cancellation token. |
| | 104 | | /// </param> |
| | 105 | | public static async Task<FaceList> GetAsync(this IFaceListOperations operations, string faceListId, bool? re |
| | 106 | | { |
| 2 | 107 | | using (var _result = await operations.GetWithHttpMessagesAsync(faceListId, returnRecognitionModel, null, |
| | 108 | | { |
| 2 | 109 | | return _result.Body; |
| | 110 | | } |
| 2 | 111 | | } |
| | 112 | |
|
| | 113 | | /// <summary> |
| | 114 | | /// Update information of a face list. |
| | 115 | | /// </summary> |
| | 116 | | /// <param name='operations'> |
| | 117 | | /// The operations group for this extension method. |
| | 118 | | /// </param> |
| | 119 | | /// <param name='faceListId'> |
| | 120 | | /// Id referencing a particular face list. |
| | 121 | | /// </param> |
| | 122 | | /// <param name='name'> |
| | 123 | | /// User defined name, maximum length is 128. |
| | 124 | | /// </param> |
| | 125 | | /// <param name='userData'> |
| | 126 | | /// User specified data. Length should not exceed 16KB. |
| | 127 | | /// </param> |
| | 128 | | /// <param name='cancellationToken'> |
| | 129 | | /// The cancellation token. |
| | 130 | | /// </param> |
| | 131 | | public static async Task UpdateAsync(this IFaceListOperations operations, string faceListId, string name = d |
| | 132 | | { |
| 0 | 133 | | (await operations.UpdateWithHttpMessagesAsync(faceListId, name, userData, null, cancellationToken).Confi |
| 0 | 134 | | } |
| | 135 | |
|
| | 136 | | /// <summary> |
| | 137 | | /// Delete a specified face list. |
| | 138 | | /// </summary> |
| | 139 | | /// <param name='operations'> |
| | 140 | | /// The operations group for this extension method. |
| | 141 | | /// </param> |
| | 142 | | /// <param name='faceListId'> |
| | 143 | | /// Id referencing a particular face list. |
| | 144 | | /// </param> |
| | 145 | | /// <param name='cancellationToken'> |
| | 146 | | /// The cancellation token. |
| | 147 | | /// </param> |
| | 148 | | public static async Task DeleteAsync(this IFaceListOperations operations, string faceListId, CancellationTok |
| | 149 | | { |
| 6 | 150 | | (await operations.DeleteWithHttpMessagesAsync(faceListId, null, cancellationToken).ConfigureAwait(false) |
| 6 | 151 | | } |
| | 152 | |
|
| | 153 | | /// <summary> |
| | 154 | | /// List face lists’ faceListId, name, userData and recognitionModel. <br |
| | 155 | | /// /> |
| | 156 | | /// To get face information inside faceList use [FaceList - |
| | 157 | | /// Get](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524c) |
| | 158 | | /// |
| | 159 | | /// </summary> |
| | 160 | | /// <param name='operations'> |
| | 161 | | /// The operations group for this extension method. |
| | 162 | | /// </param> |
| | 163 | | /// <param name='returnRecognitionModel'> |
| | 164 | | /// A value indicating whether the operation should return 'recognitionModel' |
| | 165 | | /// in response. |
| | 166 | | /// </param> |
| | 167 | | /// <param name='cancellationToken'> |
| | 168 | | /// The cancellation token. |
| | 169 | | /// </param> |
| | 170 | | public static async Task<IList<FaceList>> ListAsync(this IFaceListOperations operations, bool? returnRecogni |
| | 171 | | { |
| 0 | 172 | | using (var _result = await operations.ListWithHttpMessagesAsync(returnRecognitionModel, null, cancellati |
| | 173 | | { |
| 0 | 174 | | return _result.Body; |
| | 175 | | } |
| 0 | 176 | | } |
| | 177 | |
|
| | 178 | | /// <summary> |
| | 179 | | /// Delete a face from a face list by specified faceListId and persistedFaceId. |
| | 180 | | /// <br /> Adding/deleting faces to/from a same face list are processed |
| | 181 | | /// sequentially and to/from different face lists are in parallel. |
| | 182 | | /// </summary> |
| | 183 | | /// <param name='operations'> |
| | 184 | | /// The operations group for this extension method. |
| | 185 | | /// </param> |
| | 186 | | /// <param name='faceListId'> |
| | 187 | | /// Id referencing a particular face list. |
| | 188 | | /// </param> |
| | 189 | | /// <param name='persistedFaceId'> |
| | 190 | | /// Id referencing a particular persistedFaceId of an existing face. |
| | 191 | | /// </param> |
| | 192 | | /// <param name='cancellationToken'> |
| | 193 | | /// The cancellation token. |
| | 194 | | /// </param> |
| | 195 | | public static async Task DeleteFaceAsync(this IFaceListOperations operations, string faceListId, System.Guid |
| | 196 | | { |
| 0 | 197 | | (await operations.DeleteFaceWithHttpMessagesAsync(faceListId, persistedFaceId, null, cancellationToken). |
| 0 | 198 | | } |
| | 199 | |
|
| | 200 | | /// <summary> |
| | 201 | | /// Add a face to a specified face list, up to 1,000 faces. |
| | 202 | | /// <br /> To deal with an image contains multiple faces, input face can |
| | 203 | | /// be specified as an image with a targetFace rectangle. It returns a |
| | 204 | | /// persistedFaceId representing the added face. No image will be stored. Only |
| | 205 | | /// the extracted face feature will be stored on server until [FaceList - |
| | 206 | | /// Delete |
| | 207 | | /// Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395251) |
| | 208 | | /// or [FaceList - |
| | 209 | | /// Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) |
| | 210 | | /// is called. |
| | 211 | | /// <br /> Note persistedFaceId is different from faceId generated by |
| | 212 | | /// [Face - |
| | 213 | | /// Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236). |
| | 214 | | /// * Higher face image quality means better detection and recognition |
| | 215 | | /// precision. Please consider high-quality faces: frontal, clear, and face |
| | 216 | | /// size is 200x200 pixels (100 pixels between eyes) or bigger. |
| | 217 | | /// * JPEG, PNG, GIF (the first frame), and BMP format are supported. The |
| | 218 | | /// allowed image file size is from 1KB to 6MB. |
| | 219 | | /// * "targetFace" rectangle should contain one face. Zero or multiple faces |
| | 220 | | /// will be regarded as an error. If the provided "targetFace" rectangle is not |
| | 221 | | /// returned from [Face - |
| | 222 | | /// Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), |
| | 223 | | /// there’s no guarantee to detect and add the face successfully. |
| | 224 | | /// * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, |
| | 225 | | /// or large occlusions will cause failures. |
| | 226 | | /// * Adding/deleting faces to/from a same face list are processed sequentially |
| | 227 | | /// and to/from different face lists are in parallel. |
| | 228 | | /// * The minimum detectable face size is 36x36 pixels in an image no larger |
| | 229 | | /// than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels |
| | 230 | | /// will need a proportionally larger minimum face size. |
| | 231 | | /// * Different 'detectionModel' values can be provided. To use and compare |
| | 232 | | /// different detection models, please refer to [How to specify a detection |
| | 233 | | /// model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-det |
| | 234 | | /// | Model | Recommended use-case(s) | |
| | 235 | | /// | ---------- | -------- | |
| | 236 | | /// | 'detection_01': | The default detection model for [FaceList - Add |
| | 237 | | /// Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250). |
| | 238 | | /// Recommend for near frontal face detection. For scenarios with exceptionally |
| | 239 | | /// large angle (head-pose) faces, occluded faces or wrong image orientation, |
| | 240 | | /// the faces in such cases may not be detected. | |
| | 241 | | /// | 'detection_02': | Detection model released in 2019 May with improved |
| | 242 | | /// accuracy especially on small, side and blurry faces. | |
| | 243 | | /// </summary> |
| | 244 | | /// <param name='operations'> |
| | 245 | | /// The operations group for this extension method. |
| | 246 | | /// </param> |
| | 247 | | /// <param name='faceListId'> |
| | 248 | | /// Id referencing a particular face list. |
| | 249 | | /// </param> |
| | 250 | | /// <param name='url'> |
| | 251 | | /// Publicly reachable URL of an image |
| | 252 | | /// </param> |
| | 253 | | /// <param name='userData'> |
| | 254 | | /// User-specified data about the face for any purpose. The maximum length is |
| | 255 | | /// 1KB. |
| | 256 | | /// </param> |
| | 257 | | /// <param name='targetFace'> |
| | 258 | | /// A face rectangle to specify the target face to be added to a person in the |
| | 259 | | /// format of "targetFace=left,top,width,height". E.g. |
| | 260 | | /// "targetFace=10,10,100,100". If there is more than one face in the image, |
| | 261 | | /// targetFace is required to specify which face to add. No targetFace means |
| | 262 | | /// there is only one face detected in the entire image. |
| | 263 | | /// </param> |
| | 264 | | /// <param name='detectionModel'> |
| | 265 | | /// Name of detection model. Detection model is used to detect faces in the |
| | 266 | | /// submitted image. A detection model name can be provided when performing |
| | 267 | | /// Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add |
| | 268 | | /// Face. The default value is 'detection_01', if another model is needed, |
| | 269 | | /// please explicitly specify it. Possible values include: 'detection_01', |
| | 270 | | /// 'detection_02' |
| | 271 | | /// </param> |
| | 272 | | /// <param name='cancellationToken'> |
| | 273 | | /// The cancellation token. |
| | 274 | | /// </param> |
| | 275 | | public static async Task<PersistedFace> AddFaceFromUrlAsync(this IFaceListOperations operations, string face |
| | 276 | | { |
| 0 | 277 | | using (var _result = await operations.AddFaceFromUrlWithHttpMessagesAsync(faceListId, url, userData, tar |
| | 278 | | { |
| 0 | 279 | | return _result.Body; |
| | 280 | | } |
| 0 | 281 | | } |
| | 282 | |
|
| | 283 | | /// <summary> |
| | 284 | | /// Add a face to a specified face list, up to 1,000 faces. |
| | 285 | | /// <br /> To deal with an image contains multiple faces, input face can |
| | 286 | | /// be specified as an image with a targetFace rectangle. It returns a |
| | 287 | | /// persistedFaceId representing the added face. No image will be stored. Only |
| | 288 | | /// the extracted face feature will be stored on server until [FaceList - |
| | 289 | | /// Delete |
| | 290 | | /// Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395251) |
| | 291 | | /// or [FaceList - |
| | 292 | | /// Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) |
| | 293 | | /// is called. |
| | 294 | | /// <br /> Note persistedFaceId is different from faceId generated by |
| | 295 | | /// [Face - |
| | 296 | | /// Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236). |
| | 297 | | /// * Higher face image quality means better detection and recognition |
| | 298 | | /// precision. Please consider high-quality faces: frontal, clear, and face |
| | 299 | | /// size is 200x200 pixels (100 pixels between eyes) or bigger. |
| | 300 | | /// * JPEG, PNG, GIF (the first frame), and BMP format are supported. The |
| | 301 | | /// allowed image file size is from 1KB to 6MB. |
| | 302 | | /// * "targetFace" rectangle should contain one face. Zero or multiple faces |
| | 303 | | /// will be regarded as an error. If the provided "targetFace" rectangle is not |
| | 304 | | /// returned from [Face - |
| | 305 | | /// Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), |
| | 306 | | /// there’s no guarantee to detect and add the face successfully. |
| | 307 | | /// * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, |
| | 308 | | /// or large occlusions will cause failures. |
| | 309 | | /// * Adding/deleting faces to/from a same face list are processed sequentially |
| | 310 | | /// and to/from different face lists are in parallel. |
| | 311 | | /// * The minimum detectable face size is 36x36 pixels in an image no larger |
| | 312 | | /// than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels |
| | 313 | | /// will need a proportionally larger minimum face size. |
| | 314 | | /// * Different 'detectionModel' values can be provided. To use and compare |
| | 315 | | /// different detection models, please refer to [How to specify a detection |
| | 316 | | /// model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-det |
| | 317 | | /// | Model | Recommended use-case(s) | |
| | 318 | | /// | ---------- | -------- | |
| | 319 | | /// | 'detection_01': | The default detection model for [FaceList - Add |
| | 320 | | /// Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250). |
| | 321 | | /// Recommend for near frontal face detection. For scenarios with exceptionally |
| | 322 | | /// large angle (head-pose) faces, occluded faces or wrong image orientation, |
| | 323 | | /// the faces in such cases may not be detected. | |
| | 324 | | /// | 'detection_02': | Detection model released in 2019 May with improved |
| | 325 | | /// accuracy especially on small, side and blurry faces. | |
| | 326 | | /// </summary> |
| | 327 | | /// <param name='operations'> |
| | 328 | | /// The operations group for this extension method. |
| | 329 | | /// </param> |
| | 330 | | /// <param name='faceListId'> |
| | 331 | | /// Id referencing a particular face list. |
| | 332 | | /// </param> |
| | 333 | | /// <param name='image'> |
| | 334 | | /// An image stream. |
| | 335 | | /// </param> |
| | 336 | | /// <param name='userData'> |
| | 337 | | /// User-specified data about the face for any purpose. The maximum length is |
| | 338 | | /// 1KB. |
| | 339 | | /// </param> |
| | 340 | | /// <param name='targetFace'> |
| | 341 | | /// A face rectangle to specify the target face to be added to a person in the |
| | 342 | | /// format of "targetFace=left,top,width,height". E.g. |
| | 343 | | /// "targetFace=10,10,100,100". If there is more than one face in the image, |
| | 344 | | /// targetFace is required to specify which face to add. No targetFace means |
| | 345 | | /// there is only one face detected in the entire image. |
| | 346 | | /// </param> |
| | 347 | | /// <param name='detectionModel'> |
| | 348 | | /// Name of detection model. Detection model is used to detect faces in the |
| | 349 | | /// submitted image. A detection model name can be provided when performing |
| | 350 | | /// Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add |
| | 351 | | /// Face. The default value is 'detection_01', if another model is needed, |
| | 352 | | /// please explicitly specify it. Possible values include: 'detection_01', |
| | 353 | | /// 'detection_02' |
| | 354 | | /// </param> |
| | 355 | | /// <param name='cancellationToken'> |
| | 356 | | /// The cancellation token. |
| | 357 | | /// </param> |
| | 358 | | public static async Task<PersistedFace> AddFaceFromStreamAsync(this IFaceListOperations operations, string f |
| | 359 | | { |
| 14 | 360 | | using (var _result = await operations.AddFaceFromStreamWithHttpMessagesAsync(faceListId, image, userData |
| | 361 | | { |
| 14 | 362 | | return _result.Body; |
| | 363 | | } |
| 14 | 364 | | } |
| | 365 | |
|
| | 366 | | } |
| | 367 | | } |