示例#1
0
        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));
        }
示例#2
0
        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;
            }
        }
示例#3
0
        public static async Task <JsonResponseMessage <Person> > Recognize(WebEntity.Face face)
        {
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage response = await client.PostAsJsonAsync(
                "faceweb/recognize", face);

            Console.WriteLine(response.Content);
            Console.WriteLine("RequestMessageContect " + response.RequestMessage.Content);
            return(await response.Content.ReadAsAsync <JsonResponseMessage <Person> >());
        }