//注册按钮点击 private void signIn_btn_Click(object sender, EventArgs e) { string groupId = groupId_tb.Text; string userId = userId_tb.Text; string userName = UserName_tb.Text; if (String.IsNullOrEmpty(groupId)) { groupId_tb.Focus(); return; } if (String.IsNullOrEmpty(userId)) { userId_tb.Focus(); return; } if (String.IsNullOrEmpty(userName)) { UserName_tb.Focus(); return; } // 如果有可选参数 var options = new Dictionary <string, object> { { "user_info", userName }, { "quality_control", "NORMAL" }, { "liveness_control", "NORMAL" } }; var count = imageLists.Images.Count; for (int i = 0; i < count; i++) { var imageBytes = File.ReadAllBytes(FaceList[i]); var image = Convert.ToBase64String(imageBytes); //调用封装的人脸注册服务 var jresult = BaiduUtils.addUser(image, groupId, userId, userName); if (jresult.Equals("SUCCESS")) { Userinfolist.Add(new UserInfo() { group_id = groupId, user_id = userId, user_info = userName }); MessageBox.Show("注册成功!"); } else { MessageBox.Show("注册失败:" + jresult.ToString()); } } }
private void signIn_btn_Click(object sender, EventArgs e) { string groupId = groupId_tb.Text; string userId = userId_tb.Text; string userName = UserName_tb.Text; if (String.IsNullOrEmpty(groupId)) { groupId_tb.Focus(); return; } if (String.IsNullOrEmpty(userId)) { userId_tb.Focus(); return; } if (String.IsNullOrEmpty(userName)) { UserName_tb.Focus(); return; } // 如果有可选参数 var options = new Dictionary <string, object> { { "user_info", userName }, { "quality_control", "NORMAL" }, { "liveness_control", "NORMAL" } }; var count = imageLists.Images.Count; for (int i = 0; i < count; i++) { var imageBytes = File.ReadAllBytes(FaceList[i]); var image = Convert.ToBase64String(imageBytes); var jresult = FaceDectectHelper.UserAddDemo(image, groupId, userId, options); if (jresult != null && !String.IsNullOrEmpty(jresult.face_token)) { Userinfolist.Add(new FaceSearch() { group_id = groupId, user_id = userId, user_info = userName }); } } MessageBox.Show("注册成功!"); }