//签到-寻找人脸对应的用户 private bool UserCheckIn(byte[] imageBytes) { bool flag = false; var image = Convert.ToBase64String(imageBytes); String result = BaiduUtils.searchOneUserByImage(image); // 可选参数 var option = new Dictionary <string, object>() { { "spd", 5 }, // 语速 { "vol", 7 }, // 音量 { "per", 4 } // 发音人,4:情感度丫丫童声 }; if (result != null && result.Contains("#")) { flag = true; var time = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); CheckResult_rtb.AppendText(String.Format("{0}\t 签到时间:{1}\n", result.Split('#')[1], time)); //签到信息入数据库 MysqlUtil.addInfor(result.Split('#')[1], time); //欢迎语 SpeakHello.speech(String.Format("签到成功,欢迎{0}", result.Split('#')[1]), option); } else { SpeakHello.speech(String.Format("没有该用户的信息,请先注册"), option); } return(flag); }
public HomeForm() { InitializeComponent(); Control.CheckForIllegalCrossThreadCalls = false; //1、获取摄像头,并打开 videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); if (videoDevices.Count == 0) { MessageBox.Show("没有可用摄像头!"); } else { CurrentVideoSourcePlayer = videoSourcePlayer_UserCheckIn; videoSource = new VideoCaptureDevice(videoDevices[selectedDeviceIndex].MonikerString);//连接摄像头。 videoSource.VideoResolution = videoSource.VideoCapabilities[selectedDeviceIndex]; CurrentVideoSourcePlayer.VideoSource = videoSource; CurrentVideoSourcePlayer.Start(); } if (Userinfolist == null) { Userinfolist = new List <UserInfo>(); } //2、展示当前识别用户的历史刷脸情况 users_dataGridView.DataSource = Userinfolist; List <List <string> > infor = MysqlUtil.listInfor(); foreach (List <string> l in infor) { //作为一行输出 string line = ""; for (int i = 0; i < l.Count; i++) { //姓名:reader[1],时间:reader[2] if (i == 0) { line += "姓名:" + l[i]; } else { line += ",签到时间:" + l[i]; } } CheckResult_rtb.Text += line + System.Environment.NewLine; } }