private async void UpdatePersonAsync() { if (findFace && Person == null) { Stopwatch timer = Stopwatch.StartNew(); var face_data = new WebEntity.Face(Convert.ToBase64String(humanFace.face.ToJpegData())); try { var response = await RestfulClient.Recognize(face_data); if (response.ReturnCode == 200) { Person = response.Content; } else if (response.ReturnCode == 404) { FailToRecognize = true; } } catch (Exception ex) { Debug.WriteLine("Error on connecting server: " + ex.Message); Person = null; } timer.Stop(); TimeSpan timespan = timer.Elapsed; } }
private async void BtnCheckFace_ClickAsync(object sender, EventArgs e) { txtUsrename.Text = ""; txtDetail.Text = ""; txtScore.Text = ""; Stopwatch timer = Stopwatch.StartNew(); var face_data = new WebEntity.Face(Convert.ToBase64String(cropedFace)); try { var response = await RestfulClient.Recognize(face_data); if (response.ReturnCode == 200) { txtUsrename.Text = response.Content.Name; txtScore.Text = response.Content.Face.Score.ToString(); txtDetail.Text = response.Content.Detail; TxtErrorMessage.Text = response.Message; } else { TxtErrorMessage.Text = response.Message; } } catch (Exception ex) { Debug.WriteLine("Error on connecting server: " + ex.Message); TxtErrorMessage.Text = "Error on connecting server: " + ex.Message; } timer.Stop(); TimeSpan timespan = timer.Elapsed; Console.WriteLine(String.Format("{0:00}:{1:00}:{2:00}", timespan.Minutes, timespan.Seconds, timespan.Milliseconds / 10)); }