Exemplo n.º 1
0
        void match_img(string a)
        {
            byte[] bytes = File.ReadAllBytes(a);
            //二进制转字符串
            string base64String = Convert.ToBase64String(bytes);
            string json         = Newtonsoft.Json.JsonConvert.SerializeObject(base64String);

            TestJson(FaceSearch.search(json));
            //Console.WriteLine("Finesh");
        }
Exemplo n.º 2
0
        /// <summary>
        /// 人脸识别按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnIdentify_Click(object sender, EventArgs e)
        {
            if (videoSource == null)
            {
                return;
            }

            Bitmap bitmap = vspIdentify.GetCurrentVideoFrame();

            string[] result = FaceSearch.search(bitmap);
            bitmap.Dispose();
            txtGroup.Text         = result[0];
            txtUid.Text           = result[1];
            txtMatchingScore.Text = result[2];
        }
Exemplo n.º 3
0
        /// <summary>
        /// 在收到相机通知可以读取图像时进行图像处理
        /// </summary>
        private void handleImageDetecting()
        {
            Bitmap bitmap = vspIdentify.GetCurrentVideoFrame();//识别

            if (bitmap == null)
            {
                return;
            }

            // 控制一次只能处理一张图片
            isDetecting = true;

            // 图像识别耗时且走网络,应该考虑放到子线程执行
            new Thread(new ParameterizedThreadStart(t =>
            {
                string[] result = FaceSearch.search(bitmap);
                bitmap.Dispose();
                double score = Convert.ToDouble(result[2]);
                if (score > 80)
                {
                    // 从timer线程切换到主线程刷新UI
                    this.BeginInvoke(new MethodInvoker(delegate
                    {
                        this.Close();
                        if (FaceDetectCallback != null)
                        {
                            FaceDetectCallback(this, result[1]);
                            DataAccess.Components identity = new DataAccess.Components();
                            DataSet ds = new DataSet();
                            string pwd = "";
                            int num, num1, num2;
                            ds   = identity.stuIdentity(Convert.ToInt32(result[1]));
                            num  = ds.Tables["studentlist"].Rows.Count;
                            ds   = identity.teaIdentity(Convert.ToInt32(result[1]));
                            num1 = ds.Tables["teacherlist"].Rows.Count;
                            ds   = identity.admIdentity(Convert.ToInt32(result[1]));
                            num2 = ds.Tables["adminilist"].Rows.Count;
                            if (num > 0)
                            {
                                Liuyingjie.Student_Frm stu = new Liuyingjie.Student_Frm();
                                stu.Show();
                            }
                            else if (num1 > 0)
                            {
                                Liaobingquan.FormTeacher tea = new Liaobingquan.FormTeacher();
                                tea.Show();
                            }
                            else if (num2 > 0)
                            {
                                Lijianhua.Admin adm = new Lijianhua.Admin(result[1], pwd);
                                adm.Show();
                            }
                        }
                    }));
                }
                else
                {
                    isDetecting = false;
                }
            })).Start("tryToDetectFace");
        }