/// <summary> /// 识别 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void skinButton3_Click(object sender, EventArgs e) { if (pictureBox1.Image == null) { skinTextBox1.Text = "先点一下拍照按钮"; } else { Image image = pictureBox1.Image; label2.Text = "正在识别"; //需要异步 Task <Tuple <Image, string> > task = new Task <Tuple <Image, string> > (() => { FaceDataProvider baiduDataProvider = new FaceDataProvider(); string text = baiduDataProvider.NetFaceMatchData(image); Image imageDeal = baiduDataProvider.DrawSquar(image); Tuple <Image, string> tuple = new Tuple <Image, string>(imageDeal, text); return(tuple); }); task.Start(); task.Wait(); pictureBox1.Image = task.Result.Item1; skinTextBox1.Text = task.Result.Item2; label2.Text = ""; } }
/// <summary> /// 检测 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void skinButton2_Click(object sender, EventArgs e) { if (ifPhoto) { Image image = pictureBox1.Image; label2.Text = "正在检测"; Task <Tuple <Image, string> > task = new Task <Tuple <Image, string> >(() => { FaceDataProvider baiduDataProvider = new FaceDataProvider(); Tuple <Image, string> data = new Tuple <Image, string>(baiduDataProvider.DrawSquar(image), baiduDataProvider.NetRecognitionDataStr(image)) { }; return(data); }); task.Start(); task.Wait(); pictureBox1.Image = task.Result.Item1; skinTextBox1.Text = task.Result.Item2; label2.Text = ""; } else { skinTextBox1.Text = "先点一下拍照按钮"; } }
/// <summary> /// 识别 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SkinButton2_Click(object sender, EventArgs e) { Image image = pictureBox1.Image; label2.Text = "正在识别"; FaceDataProvider baiduDataProvider = new FaceDataProvider(); skinTextBox1.Text = baiduDataProvider.NetFaceMatchData(image); pictureBox1.Image = baiduDataProvider.DrawSquar(image); label2.Text = ""; }
/// <summary> /// 检测 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SkinButton1_Click(object sender, EventArgs e) { string path = System.IO.Path.GetFullPath(dialog.FileName); Image image = pictureBox1.Image; label2.Text = "正在检测"; Task <Tuple <Image, string> > taskK = new Task <Tuple <Image, string> >(() => { FaceDataProvider baiduDataProvider = new FaceDataProvider(); Tuple <Image, string> data = new Tuple <Image, string>(baiduDataProvider.DrawSquar(image, path), baiduDataProvider.NetRecognitionDataStr(image)) { }; return(data); }); taskK.Start(); taskK.Wait(); pictureBox1.Image = taskK.Result.Item1; skinTextBox1.Text = taskK.Result.Item2; label2.Text = ""; }