Exemplo n.º 1
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.º 2
0
        private bool UserCheckIn(byte[] imageBytes)
        {
            bool       flag   = false;
            var        image  = Convert.ToBase64String(imageBytes);
            FaceSearch result = FaceDectectHelper.SearchDemo(image);
            // 可选参数
            var option = new Dictionary <string, object>()
            {
                { "spd", 5 },   // 语速
                { "vol", 7 },   // 音量
                { "per", 4 }    // 发音人,4:情感度丫丫童声
            };

            if (result != null && result.score > 50)
            {
                flag = true;
                var time = DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss");
                CheckResult_rtb.AppendText(String.Format("{0}\t 签到时间:{1}\n", result.user_info, time));
                //签到信息入库
                MysqlUtil.addInfor(result.user_info, time);
                SpeechHelper.Tts(String.Format("签到成功,欢迎{0}", result.user_info), option);
            }
            else
            {
                SpeechHelper.Tts(String.Format("没有该用户的信息,请先注册该用户"), option);
            }

            return(flag);
        }