Esempio n. 1
0
        public Tuple <bool, string> NetFaceRegisterData(Image image, string userName, JObject info)
        {
            try
            {
                RecognitionProvider recognitionProvider = new RecognitionProvider();
                string groupId = "UsualUser";
                string userId  = ChineseToPinyin(userName).ToLower();
                info.Add("UserName", userName);
                JObject jsonData = recognitionProvider.NetFaceRegister(image, groupId, userId, info.ToString());
                jsonData.TryGetValue("error_code", out JToken errorCodeToken);
                jsonData.TryGetValue("error_msg", out JToken errorMessageToken);
                bool   mark    = true;
                string message = errorMessageToken.ToString();
                //int errorCode = int.Parse(errorCodeToken.ToString());
                string errorCode = errorCodeToken.ToString();
                switch (errorCode)
                {
                case "223105":
                    mark = false;
                    break;

                default:
                    mark = true;
                    break;
                }
                return(new Tuple <bool, string>(mark, message));
            }
            catch (Exception ex) { return(new Tuple <bool, string>(false, ex.ToString())); }
        }
Esempio n. 2
0
        public void NetFaceRegisterTest()
        {
            Image          image    = null;
            string         id       = "id";
            string         name     = "姓名";
            string         group    = "UsualUser";
            string         info     = "信息";
            string         faceInfo = name + "`" + info;
            Task <JObject> task     = new Task <JObject>(
                () =>
            {
                RecognitionProvider baiduRecognitionProvider = new RecognitionProvider();
                return(baiduRecognitionProvider.NetFaceRegister(image, group, id, faceInfo));
            });

            task.Start();
            task.Wait();
            var aaa = task.Result;
        }