Exemplo n.º 1
0
        //从列表中删除人员
        private void delete_btn_Click(object sender, EventArgs e)
        {
            var             flag = false;
            List <UserInfo> list = new List <UserInfo>();

            list.AddRange(Userinfolist.Select(x => new UserInfo(x)));
            foreach (DataGridViewRow row in users_dataGridView.SelectedRows)
            {
                var deleteUser = row.DataBoundItem as UserInfo;
                var jresult    = BaiduUtils.delUser(deleteUser.group_id, deleteUser.user_id);
                if (jresult.Equals("SUCCESS"))
                {
                    flag = true;
                    list.Remove(deleteUser);
                    MessageBox.Show("删除成功:" + jresult.ToString());
                }
                else
                {
                    MessageBox.Show("删除失败:" + jresult.ToString());
                }
            }

            if (flag)
            {
                users_dataGridView.DataSource = list;
            }
        }
Exemplo n.º 2
0
        //签到-寻找人脸对应的用户
        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);
        }
Exemplo n.º 3
0
        //注册按钮点击
        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());
                }
            }
        }
Exemplo n.º 4
0
        //增加人脸
        private string AddFace(string filePath)
        {
            if (FaceList.Contains(filePath))
            {
                return("该人脸已注册");
            }

            //处理图片为BASE64
            var imageBytes = File.ReadAllBytes(filePath);
            var image      = Convert.ToBase64String(imageBytes);

            //先进行人脸检测,检测通过后方可注册
            var result = BaiduUtils.faceDetectJudge(image);

            if (String.IsNullOrEmpty(result))
            {
                FaceList.Add(filePath);
                return("");
            }
            return(result);
        }
Exemplo n.º 5
0
        //加载主页
        private void HomeForm_Load(object sender, EventArgs e)
        {
            //得到机器所有接入的摄像设备
            videoDevices1 = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            if (videoDevices1.Count != 0)
            {
                foreach (FilterInfo device in videoDevices1)
                {
                    cboVideo.Items.Add(device.Name);//把摄像设备添加到摄像列表中
                }
            }
            else
            {
                cboVideo.Items.Add("没有找到摄像头");
            }
            cboVideo.SelectedIndex = 0;

            //查询人员列表
            Userinfolist = BaiduUtils.queryUserListByGroupId("1");

            //启动线程,5分钟刷新一次列表
            Thread objThread = new Thread(new ThreadStart(delegate
            {
                while (true)
                {
                    try
                    {
                        Thread.Sleep(1000 * 5);
                        var result = BaiduUtils.queryUserListByGroupId("1");
                        if (result.Count > 0)
                        {
                            Userinfolist = result;
                        }
                    }
                    catch (Exception e1) { }
                }
            }));

            objThread.Start();
        }