-
Notifications
You must be signed in to change notification settings - Fork 167
/
Face.cs
593 lines (518 loc) · 13.8 KB
/
Face.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
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.
//
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
//
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
// https://github.com/Microsoft/Cognitive-Face-Windows
//
// Copyright (c) Microsoft Corporation
// All rights reserved.
//
// MIT License:
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media;
namespace Microsoft.ProjectOxford.Face.Controls
{
/// <summary>
/// Face view model
/// </summary>
public class Face : INotifyPropertyChanged
{
#region Fields
/// <summary>
/// Face age text string
/// </summary>
private string _age;
/// <summary>
/// Face gender text string
/// </summary>
private string _gender;
/// <summary>
/// confidence value of this face to a target face
/// </summary>
private double _confidence;
/// <summary>
/// Person name
/// </summary>
private string _personName;
/// <summary>
/// Face height in pixel
/// </summary>
private int _height;
/// <summary>
/// Face position X relative to image left-top in pixel
/// </summary>
private int _left;
/// <summary>
/// Face position Y relative to image left-top in pixel
/// </summary>
private int _top;
/// <summary>
/// Face original position X relative to image left-top in pixel
/// </summary>
private int _originalLeft;
/// <summary>
/// Face original position Y relative to image left-top in pixel
/// </summary>
private int _originalTop;
/// <summary>
/// Face width in pixel
/// </summary>
private int _width;
/// <summary>
/// Face angle
/// </summary>
private double _faceAngle;
/// <summary>
/// Indicates the headPose
/// </summary>
private string _headPose;
/// <summary>
/// Facial hair display string
/// </summary>
private string _facialHair;
/// <summary>
/// Indicates the glasses type
/// </summary>
private string _glasses;
/// <summary>
/// Indicates the emotion
/// </summary>
private string _emotion;
/// <summary>
/// Indicates the hair
/// </summary>
private string _hair;
/// <summary>
/// Indicates the makeup
/// </summary>
private string _makeup;
/// <summary>
/// Indicates the eye occlusion
/// </summary>
private string _eyeOcclusion;
/// <summary>
/// Indicates the forehead occlusion
/// </summary>
private string _foreheadOcclusion;
/// <summary>
/// Indicates the mouth occlusion
/// </summary>
private string _mouthOcclusion;
/// <summary>
/// Indicates the accessories
/// </summary>
private string _accessories;
/// <summary>
/// Indicates the blur
/// </summary>
private string _blur;
/// <summary>
/// Indicates the exposure
/// </summary>
private string _exposure;
/// <summary>
/// Indicates the noise
/// </summary>
private string _noise;
#endregion Fields
#region Events
/// <summary>
/// Implement INotifyPropertyChanged interface
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
#endregion Events
#region Properties
/// <summary>
/// Gets or sets age text string
/// </summary>
public string Age
{
get
{
return _age;
}
set
{
_age = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets gender text string
/// </summary>
public string Gender
{
get
{
return _gender;
}
set
{
_gender = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets confidence value
/// </summary>
public double Confidence
{
get
{
return _confidence;
}
set
{
_confidence = value;
OnPropertyChanged<double>();
}
}
/// <summary>
/// Gets face rectangle on image
/// </summary>
public System.Windows.Int32Rect UIRect
{
get
{
return new System.Windows.Int32Rect(Left, Top, Width, Height);
}
}
/// <summary>
/// Gets or sets image path
/// </summary>
public ImageSource ImageFile
{
get;
set;
}
/// <summary>
/// Gets or sets face id
/// </summary>
public string FaceId
{
get;
set;
}
/// <summary>
/// Gets or sets person's name
/// </summary>
public string PersonName
{
get
{
return _personName;
}
set
{
_personName = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets face height
/// </summary>
public int Height
{
get
{
return _height;
}
set
{
_height = value;
OnPropertyChanged<int>();
}
}
/// <summary>
/// Gets or sets face position X
/// </summary>
public int Left
{
get
{
return _left;
}
set
{
_left = value;
OnPropertyChanged<int>();
}
}
/// <summary>
/// Gets or sets face position Y
/// </summary>
public int Top
{
get
{
return _top;
}
set
{
_top = value;
OnPropertyChanged<int>();
}
}
/// <summary>
/// Gets or sets face original position X
/// </summary>
public int OriginalLeft
{
get
{
return _originalLeft;
}
set
{
_originalLeft = value;
OnPropertyChanged<int>();
}
}
/// <summary>
/// Gets or sets face original position Y
/// </summary>
public int OriginalTop
{
get
{
return _originalTop;
}
set
{
_originalTop = value;
OnPropertyChanged<int>();
}
}
/// <summary>
/// Gets or sets face width
/// </summary>
public int Width
{
get
{
return _width;
}
set
{
_width = value;
OnPropertyChanged<int>();
}
}
/// <summary>
/// Gets or sets face angle
/// </summary>
public double FaceAngle
{
get
{
return _faceAngle;
}
set
{
_faceAngle = value;
OnPropertyChanged<int>();
}
}
/// <summary>
/// Gets or sets a value indicating the head pose value
/// </summary>
public string HeadPose
{
get { return _headPose; }
set
{
_headPose = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets facial hair display string
/// </summary>
public string FacialHair
{
get
{
return _facialHair;
}
set
{
_facialHair = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the glasses type
/// </summary>
public string Glasses
{
get
{
return _glasses;
}
set
{
_glasses = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the emotion type
/// </summary>
public string Emotion
{
get { return _emotion; }
set
{
_emotion = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the hair type
/// </summary>
public string Hair
{
get { return _hair; }
set
{
_hair = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the makeup type
/// </summary>
public string Makeup
{
get { return _makeup; }
set
{
_makeup = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the occlusion type of eye
/// </summary>
public string EyeOcclusion
{
get { return _eyeOcclusion; }
set
{
_eyeOcclusion = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the occlusion type of forehead
/// </summary>
public string ForeheadOcclusion
{
get { return _foreheadOcclusion; }
set
{
_foreheadOcclusion = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the occlusion type of mouth
/// </summary>
public string MouthOcclusion
{
get { return _mouthOcclusion; }
set
{
_mouthOcclusion = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the accessories type
/// </summary>
public string Accessories
{
get { return _accessories; }
set
{
_accessories = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the blur type
/// </summary>
public string Blur
{
get { return _blur; }
set
{
_blur = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the exposure type
/// </summary>
public string Exposure
{
get { return _exposure; }
set
{
_exposure = value;
OnPropertyChanged<string>();
}
}
/// <summary>
/// Gets or sets a value indicating the noise type
/// </summary>
public string Noise
{
get { return _noise; }
set
{
_noise = value;
OnPropertyChanged<string>();
}
}
#endregion Properties
#region Methods
/// <summary>
/// NotifyProperty Helper functions
/// </summary>
/// <typeparam name="T">property type</typeparam>
/// <param name="caller">property change caller</param>
private void OnPropertyChanged<T>([CallerMemberName]string caller = null)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(caller));
}
}
#endregion Methods
}
}