@@ -75,13 +75,15 @@ private void ImageSelect_Click(object sender, EventArgs e)
75
75
bool enable = ! string . IsNullOrWhiteSpace ( _imageFileName ) ;
76
76
DetectFaceBtn . Enabled = DetectSceneBtn . Enabled = DetectObjectsBtn . Enabled = enable ;
77
77
}
78
+
78
79
private void ImageFileName_TextChanged ( object sender , EventArgs e )
79
80
{
80
81
_imageFileName = ImageFileName . Text ;
81
82
82
83
bool enable = ! string . IsNullOrWhiteSpace ( _imageFileName ) ;
83
84
DetectFaceBtn . Enabled = DetectSceneBtn . Enabled = DetectObjectsBtn . Enabled = enable ;
84
85
}
86
+
85
87
private void FaceImage1Select_Click ( object sender , EventArgs e )
86
88
{
87
89
CompareFacesBtn . Enabled = false ;
@@ -176,16 +178,16 @@ private async void DetectFaceBtn_Click(object sender, EventArgs e)
176
178
177
179
List < string > lines = new ( ) ;
178
180
179
- if ( detectedFaces . predictions is not null )
181
+ if ( detectedFaces . Predictions is not null )
180
182
{
181
- foreach ( var ( face , index ) in detectedFaces . predictions
183
+ foreach ( var ( face , index ) in detectedFaces . Predictions
182
184
. Select ( ( face , index ) => ( face , index ) ) )
183
185
{
184
- lines . Add ( $ "{ index } : Confidence: { Math . Round ( face . confidence , 3 ) } ") ;
186
+ lines . Add ( $ "{ index } : Confidence: { Math . Round ( face . Confidence * 100.0 , 2 ) } ") ;
185
187
186
- var rect = Rectangle . FromLTRB ( face . x_min , face . y_min , face . x_max , face . y_max ) ;
188
+ var rect = Rectangle . FromLTRB ( face . X_min , face . Y_min , face . X_max , face . Y_max ) ;
187
189
canvas . DrawRectangle ( _boundingBoxPen , rect ) ;
188
- canvas . DrawString ( index . ToString ( ) , _textFont , _textBrush , face . x_min , face . y_min ) ;
190
+ canvas . DrawString ( index . ToString ( ) , _textFont , _textBrush , face . X_min , face . Y_min ) ;
189
191
}
190
192
191
193
detectionResult . Lines = lines . ToArray ( ) ;
@@ -219,7 +221,7 @@ private async void CompareFacesBtn_Click(object sender, EventArgs e)
219
221
var result = await _serverClient . MatchFaces ( _faceImageFileName1 , _faceImageFileName2 ) ;
220
222
if ( result is MatchFacesResponse matchedFaces )
221
223
{
222
- detectionResult . Text = $ "Similarity: { Math . Round ( matchedFaces . similarity , 4 ) } ";
224
+ detectionResult . Text = $ "Similarity: { Math . Round ( matchedFaces . Similarity , 4 ) } ";
223
225
SetStatus ( "Face Comparison complete" ) ;
224
226
}
225
227
else
@@ -245,7 +247,7 @@ private async void DetectSceneBtn_Click(object sender, EventArgs e)
245
247
var image = GetImage ( _imageFileName ) ;
246
248
pictureBox1 . Image = image ;
247
249
248
- detectionResult . Text = $ "Confidence: { Math . Round ( detectedScene . confidence , 3 ) } Label: { detectedScene . label } ";
250
+ detectionResult . Text = $ "Confidence: { Math . Round ( detectedScene . Confidence * 100.0 , 2 ) } Label: { detectedScene . Label } ";
249
251
SetStatus ( "Scene Detection complete" ) ;
250
252
}
251
253
else
@@ -275,14 +277,14 @@ private async void DetectObjectsBtn_Click(object sender, EventArgs e)
275
277
try
276
278
{
277
279
lines . Add ( stopwatch . Elapsed . ToString ( ) ) ;
278
- if ( detectedObjects . predictions is not null )
279
- foreach ( var ( detectedObj , index ) in detectedObjects . predictions
280
+ if ( detectedObjects . Predictions is not null )
281
+ foreach ( var ( detectedObj , index ) in detectedObjects . Predictions
280
282
. Select ( ( detected , index ) => ( detected , index ) ) )
281
283
{
282
- lines . Add ( $ "{ index } : Conf: { Math . Round ( detectedObj . confidence , 3 ) } { detectedObj . label } ") ;
284
+ lines . Add ( $ "{ index } : Conf: { Math . Round ( detectedObj . Confidence * 100.0 , 2 ) } { detectedObj . Label } ") ;
283
285
284
- var rect = Rectangle . FromLTRB ( detectedObj . x_min , detectedObj . y_min ,
285
- detectedObj . x_max , detectedObj . y_max ) ;
286
+ var rect = Rectangle . FromLTRB ( detectedObj . X_min , detectedObj . Y_min ,
287
+ detectedObj . X_max , detectedObj . Y_max ) ;
286
288
}
287
289
288
290
detectionResult . Lines = lines . ToArray ( ) ;
@@ -296,16 +298,16 @@ private async void DetectObjectsBtn_Click(object sender, EventArgs e)
296
298
297
299
Graphics canvas = Graphics . FromImage ( image ) ;
298
300
299
- if ( detectedObjects . predictions is not null )
301
+ if ( detectedObjects . Predictions is not null )
300
302
{
301
- foreach ( var ( detectedObj , index ) in detectedObjects . predictions
303
+ foreach ( var ( detectedObj , index ) in detectedObjects . Predictions
302
304
. Select ( ( detected , index ) => ( detected , index ) ) )
303
305
{
304
- var rect = Rectangle . FromLTRB ( detectedObj . x_min , detectedObj . y_min ,
305
- detectedObj . x_max , detectedObj . y_max ) ;
306
+ var rect = Rectangle . FromLTRB ( detectedObj . X_min , detectedObj . Y_min ,
307
+ detectedObj . X_max , detectedObj . Y_max ) ;
306
308
canvas . DrawRectangle ( _boundingBoxPen , rect ) ;
307
- canvas . DrawString ( $ "{ index } :{ detectedObj . label } ", _textFont , _textBrush ,
308
- detectedObj . x_min , detectedObj . y_min ) ;
309
+ canvas . DrawString ( $ "{ index } :{ detectedObj . Label } ", _textFont , _textBrush ,
310
+ detectedObj . X_min , detectedObj . Y_min ) ;
309
311
}
310
312
}
311
313
@@ -314,7 +316,7 @@ private async void DetectObjectsBtn_Click(object sender, EventArgs e)
314
316
}
315
317
catch ( Exception ex )
316
318
{
317
- ProcessError ( new ErrorResponse ( ex . Message ) ) ;
319
+ ProcessError ( new ServerErrorResponse ( ex . Message ) ) ;
318
320
detectionResult . Lines = lines . ToArray ( ) ;
319
321
}
320
322
}
@@ -328,6 +330,7 @@ private void OnUserIdTextboxChanged(object sender, EventArgs e)
328
330
{
329
331
DeleteFaceBtn . Enabled = ! string . IsNullOrWhiteSpace ( UserIdTextbox . Text ) ;
330
332
}
333
+
331
334
private async void RegisterFaceBtn_Click ( object sender , EventArgs e )
332
335
{
333
336
ClearResults ( ) ;
@@ -376,18 +379,18 @@ private async void RecognizeFaceBtn_Click(object sender, EventArgs e)
376
379
Graphics canvas = Graphics . FromImage ( image ) ;
377
380
378
381
List < string > lines = new ( ) ;
379
- if ( recognizeFace . predictions is not null )
382
+ if ( recognizeFace . Predictions is not null )
380
383
{
381
- var predictionMap = recognizeFace . predictions
384
+ var predictionMap = recognizeFace . Predictions
382
385
. Select ( ( prediction , Index ) => ( prediction , Index ) ) ;
383
386
foreach ( var ( prediction , index ) in predictionMap )
384
387
{
385
- lines . Add ( $ "{ index } : Conf: { Math . Round ( prediction . confidence , 3 ) } { prediction . userid } ") ;
386
- var rect = Rectangle . FromLTRB ( prediction . x_min , prediction . y_min ,
387
- prediction . x_max , prediction . y_max ) ;
388
+ lines . Add ( $ "{ index } : Conf: { Math . Round ( prediction . Confidence * 100.0 , 2 ) } { prediction . Userid } ") ;
389
+ var rect = Rectangle . FromLTRB ( prediction . X_min , prediction . Y_min ,
390
+ prediction . X_max , prediction . Y_max ) ;
388
391
canvas . DrawRectangle ( _boundingBoxPen , rect ) ;
389
- canvas . DrawString ( $ "{ index } :{ prediction . userid } ", _textFont , _textBrush ,
390
- prediction . x_min , prediction . y_min ) ;
392
+ canvas . DrawString ( $ "{ index } :{ prediction . Userid } ", _textFont , _textBrush ,
393
+ prediction . X_min , prediction . Y_min ) ;
391
394
}
392
395
393
396
detectionResult . Lines = lines . ToArray ( ) ;
@@ -398,7 +401,7 @@ private async void RecognizeFaceBtn_Click(object sender, EventArgs e)
398
401
}
399
402
catch ( Exception ex )
400
403
{
401
- ProcessError ( new ErrorResponse ( $ "{ filename } caused: { ex . Message } ") ) ;
404
+ ProcessError ( new ServerErrorResponse ( $ "{ filename } caused: { ex . Message } ") ) ;
402
405
}
403
406
}
404
407
else
@@ -410,15 +413,15 @@ private async void ListFacesBtn_Click(object sender, EventArgs e)
410
413
ClearResults ( ) ;
411
414
SetStatus ( "Listing known faces" ) ;
412
415
413
- var result = await _serverClient . ListRegisteredFaces ( ) as ModuleResponseBase ;
416
+ var result = await _serverClient . ListRegisteredFaces ( ) ;
414
417
if ( result is ListRegisteredFacesResponse registeredFaces )
415
418
{
416
419
if ( result ? . Success ?? false )
417
420
{
418
421
List < string > lines = new ( ) ;
419
- if ( registeredFaces . faces != null )
422
+ if ( registeredFaces . Faces != null )
420
423
{
421
- var faceMap = registeredFaces . faces . Select ( ( face , Index ) => ( face , Index ) ) ;
424
+ var faceMap = registeredFaces . Faces . Select ( ( face , Index ) => ( face , Index ) ) ;
422
425
foreach ( var ( face , index ) in faceMap )
423
426
{
424
427
lines . Add ( $ "{ index } : { face } ") ;
@@ -455,7 +458,7 @@ private async void DeleteFaceBtn_Click(object sender, EventArgs e)
455
458
ClearResults ( ) ;
456
459
SetStatus ( "Deleting registered face" ) ;
457
460
458
- var result = await _serverClient . DeleteRegisteredFace ( UserIdTextbox . Text ) as ModuleResponseBase ;
461
+ var result = await _serverClient . DeleteRegisteredFace ( UserIdTextbox . Text ) ;
459
462
if ( result ? . Success ?? false )
460
463
SetStatus ( "Completed Face deletion" ) ;
461
464
else
@@ -545,7 +548,7 @@ private void ProcessError(ServerResponse? result)
545
548
pictureBox1 . Image = null ;
546
549
detectionResult . Text = string . Empty ;
547
550
548
- if ( result is ErrorResponse response )
551
+ if ( result is ServerErrorResponse response )
549
552
ShowError ( $ "Error: { response . Code } - { response . Error ?? "No Error Message" } ") ;
550
553
else if ( result is null )
551
554
ShowError ( "Null result" ) ;
0 commit comments