private void TiJiao_button_Click(object sender, EventArgs e) { if (videoSource == null) { MessageBox.Show("请先打开摄像头"); return; } //videoSourcePlayer继承Control父类,定义 GetCurrentVideoFrame能输出bitmap Bitmap bitmap = videoSourcePlayer1.GetCurrentVideoFrame(); pictureBox1.Image = bitmap; this.videoSourcePlayer1.Visible = false; this.pictureBox1.Visible = true; //这里停止摄像头继续工作 当然videoSourcePlayer里也定义了 Stop();用哪个都行 // string imagestr = this.pictureBox1.Image.ToString(); // bitmap = videoSourcePlayer1.GetCurrentVideoFrame(); String imagestr = Util.ImgToBase64String(bitmap); // MessageBox.Show("01", imagestr.Substring(1, 10)); videoSourcePlayer1.Stop(); //检索人脸是否存在 SearchResult searchResult = FaceSearch.faceSearch(imagestr); if (searchResult.error_msg.Equals("SUCCESS") && searchResult.result.user_list[0].user_id.Equals(this.EmployeeID)) { MessageBox.Show("已采集,不可重复采集", "提示信息"); } else { AddResult result = FaceAdd.add(imagestr, this.EmployeeID); if (result.error_msg.Equals("SUCCESS")) { MessageBox.Show("采集成功", "提示信息"); this.Close(); } else { MessageBox.Show("采集未成功", "提示信息"); } } }
private void checkFace(string image) { //识别 SearchResult searchResult = FaceSearch.faceSearch(image); if (searchResult.error_msg.Equals("SUCCESS")) { string score = searchResult.result.user_list[0].score; // MessageBox.Show(score); if (Double.Parse(score) > 85.0) { this.EmployeeID = searchResult.result.user_list[0].user_id; MessageBox.Show("验证成功"); } else { MessageBox.Show("未成功,请确认已采集人脸后再试!", "验证失败"); } } else { MessageBox.Show("未成功,请确认已采集人脸后再试!", "验证失败"); } }