Example #1
0
 public void NetTwoFaceMatchTest()
 {
     Image image1 = null;
     Image image2 = null;
     RecognitionProvider baiduRecognitionProvider = new RecognitionProvider();
     var data = baiduRecognitionProvider.NetTwoFaceMatch(image1, image2);
 }
Example #2
0
        /// <summary>
        /// 两张人脸对比
        /// </summary>
        /// <param name="sourceImage">原来的脸</param>
        /// <param name="matchImage">需要对比的脸</param>
        /// <returns></returns>
        public Tuple <bool, bool, string> NetTowFaceMatchData(Image sourceImage, Image matchImage)
        {
            try
            {
                RecognitionProvider recognitionProvider = new RecognitionProvider();
                JObject             jsonData            = recognitionProvider.NetTwoFaceMatch(sourceImage, matchImage);
                jsonData.TryGetValue("error_code", out JToken errorCodeToken);
                jsonData.TryGetValue("error_msg", out JToken errorMessageToken);
                jsonData.TryGetValue("result", out JToken value);
                float score  = (float)value["score"];
                bool  sucess = false;
                bool  match  = false;
                if (80 < score)
                {
                    match = true;
                }
                if (errorCodeToken.ToString() == "0")
                {
                    sucess = true;
                }

                return(new Tuple <bool, bool, string>(match, sucess, errorMessageToken.ToString()));
            }
            catch (Exception e)
            {
                return(new Tuple <bool, bool, string>(false, false, e.ToString()));
            }
        }