@@ -75,13 +75,15 @@ private void ImageSelect_Click(object sender, EventArgs e)
7575 bool enable = ! string . IsNullOrWhiteSpace ( _imageFileName ) ;
7676 DetectFaceBtn . Enabled = DetectSceneBtn . Enabled = DetectObjectsBtn . Enabled = enable ;
7777 }
78+
7879 private void ImageFileName_TextChanged ( object sender , EventArgs e )
7980 {
8081 _imageFileName = ImageFileName . Text ;
8182
8283 bool enable = ! string . IsNullOrWhiteSpace ( _imageFileName ) ;
8384 DetectFaceBtn . Enabled = DetectSceneBtn . Enabled = DetectObjectsBtn . Enabled = enable ;
8485 }
86+
8587 private void FaceImage1Select_Click ( object sender , EventArgs e )
8688 {
8789 CompareFacesBtn . Enabled = false ;
@@ -176,16 +178,16 @@ private async void DetectFaceBtn_Click(object sender, EventArgs e)
176178
177179 List < string > lines = new ( ) ;
178180
179- if ( detectedFaces . predictions is not null )
181+ if ( detectedFaces . Predictions is not null )
180182 {
181- foreach ( var ( face , index ) in detectedFaces . predictions
183+ foreach ( var ( face , index ) in detectedFaces . Predictions
182184 . Select ( ( face , index ) => ( face , index ) ) )
183185 {
184- lines . Add ( $ "{ index } : Confidence: { Math . Round ( face . confidence , 3 ) } ") ;
186+ lines . Add ( $ "{ index } : Confidence: { Math . Round ( face . Confidence * 100.0 , 2 ) } ") ;
185187
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 ) ;
187189 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 ) ;
189191 }
190192
191193 detectionResult . Lines = lines . ToArray ( ) ;
@@ -219,7 +221,7 @@ private async void CompareFacesBtn_Click(object sender, EventArgs e)
219221 var result = await _serverClient . MatchFaces ( _faceImageFileName1 , _faceImageFileName2 ) ;
220222 if ( result is MatchFacesResponse matchedFaces )
221223 {
222- detectionResult . Text = $ "Similarity: { Math . Round ( matchedFaces . similarity , 4 ) } ";
224+ detectionResult . Text = $ "Similarity: { Math . Round ( matchedFaces . Similarity , 4 ) } ";
223225 SetStatus ( "Face Comparison complete" ) ;
224226 }
225227 else
@@ -245,7 +247,7 @@ private async void DetectSceneBtn_Click(object sender, EventArgs e)
245247 var image = GetImage ( _imageFileName ) ;
246248 pictureBox1 . Image = image ;
247249
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 } ";
249251 SetStatus ( "Scene Detection complete" ) ;
250252 }
251253 else
@@ -275,14 +277,14 @@ private async void DetectObjectsBtn_Click(object sender, EventArgs e)
275277 try
276278 {
277279 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
280282 . Select ( ( detected , index ) => ( detected , index ) ) )
281283 {
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 } ") ;
283285
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 ) ;
286288 }
287289
288290 detectionResult . Lines = lines . ToArray ( ) ;
@@ -296,16 +298,16 @@ private async void DetectObjectsBtn_Click(object sender, EventArgs e)
296298
297299 Graphics canvas = Graphics . FromImage ( image ) ;
298300
299- if ( detectedObjects . predictions is not null )
301+ if ( detectedObjects . Predictions is not null )
300302 {
301- foreach ( var ( detectedObj , index ) in detectedObjects . predictions
303+ foreach ( var ( detectedObj , index ) in detectedObjects . Predictions
302304 . Select ( ( detected , index ) => ( detected , index ) ) )
303305 {
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 ) ;
306308 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 ) ;
309311 }
310312 }
311313
@@ -314,7 +316,7 @@ private async void DetectObjectsBtn_Click(object sender, EventArgs e)
314316 }
315317 catch ( Exception ex )
316318 {
317- ProcessError ( new ErrorResponse ( ex . Message ) ) ;
319+ ProcessError ( new ServerErrorResponse ( ex . Message ) ) ;
318320 detectionResult . Lines = lines . ToArray ( ) ;
319321 }
320322 }
@@ -328,6 +330,7 @@ private void OnUserIdTextboxChanged(object sender, EventArgs e)
328330 {
329331 DeleteFaceBtn . Enabled = ! string . IsNullOrWhiteSpace ( UserIdTextbox . Text ) ;
330332 }
333+
331334 private async void RegisterFaceBtn_Click ( object sender , EventArgs e )
332335 {
333336 ClearResults ( ) ;
@@ -376,18 +379,18 @@ private async void RecognizeFaceBtn_Click(object sender, EventArgs e)
376379 Graphics canvas = Graphics . FromImage ( image ) ;
377380
378381 List < string > lines = new ( ) ;
379- if ( recognizeFace . predictions is not null )
382+ if ( recognizeFace . Predictions is not null )
380383 {
381- var predictionMap = recognizeFace . predictions
384+ var predictionMap = recognizeFace . Predictions
382385 . Select ( ( prediction , Index ) => ( prediction , Index ) ) ;
383386 foreach ( var ( prediction , index ) in predictionMap )
384387 {
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 ) ;
388391 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 ) ;
391394 }
392395
393396 detectionResult . Lines = lines . ToArray ( ) ;
@@ -398,7 +401,7 @@ private async void RecognizeFaceBtn_Click(object sender, EventArgs e)
398401 }
399402 catch ( Exception ex )
400403 {
401- ProcessError ( new ErrorResponse ( $ "{ filename } caused: { ex . Message } ") ) ;
404+ ProcessError ( new ServerErrorResponse ( $ "{ filename } caused: { ex . Message } ") ) ;
402405 }
403406 }
404407 else
@@ -410,15 +413,15 @@ private async void ListFacesBtn_Click(object sender, EventArgs e)
410413 ClearResults ( ) ;
411414 SetStatus ( "Listing known faces" ) ;
412415
413- var result = await _serverClient . ListRegisteredFaces ( ) as ModuleResponseBase ;
416+ var result = await _serverClient . ListRegisteredFaces ( ) ;
414417 if ( result is ListRegisteredFacesResponse registeredFaces )
415418 {
416419 if ( result ? . Success ?? false )
417420 {
418421 List < string > lines = new ( ) ;
419- if ( registeredFaces . faces != null )
422+ if ( registeredFaces . Faces != null )
420423 {
421- var faceMap = registeredFaces . faces . Select ( ( face , Index ) => ( face , Index ) ) ;
424+ var faceMap = registeredFaces . Faces . Select ( ( face , Index ) => ( face , Index ) ) ;
422425 foreach ( var ( face , index ) in faceMap )
423426 {
424427 lines . Add ( $ "{ index } : { face } ") ;
@@ -455,7 +458,7 @@ private async void DeleteFaceBtn_Click(object sender, EventArgs e)
455458 ClearResults ( ) ;
456459 SetStatus ( "Deleting registered face" ) ;
457460
458- var result = await _serverClient . DeleteRegisteredFace ( UserIdTextbox . Text ) as ModuleResponseBase ;
461+ var result = await _serverClient . DeleteRegisteredFace ( UserIdTextbox . Text ) ;
459462 if ( result ? . Success ?? false )
460463 SetStatus ( "Completed Face deletion" ) ;
461464 else
@@ -545,7 +548,7 @@ private void ProcessError(ServerResponse? result)
545548 pictureBox1 . Image = null ;
546549 detectionResult . Text = string . Empty ;
547550
548- if ( result is ErrorResponse response )
551+ if ( result is ServerErrorResponse response )
549552 ShowError ( $ "Error: { response . Code } - { response . Error ?? "No Error Message" } ") ;
550553 else if ( result is null )
551554 ShowError ( "Null result" ) ;
0 commit comments