Пример #1
0
        public static BaiduLicenseRecognition getLicenseRecognition(Newtonsoft.Json.Linq.JObject jObject)
        {
            if (jObject == null)
            {
                return(null);
            }
            BaiduLicenseRecognition license = new BaiduLicenseRecognition();

            Newtonsoft.Json.Linq.JToken jtError = jObject.SelectToken("error_code");
            if (jtError != null)
            {
                license.errorCode = jtError.ToString();
                license.ErrorMsg  = jObject.SelectToken("error_msg").ToString();
                return(license);
            }
            Newtonsoft.Json.Linq.JToken wordsResult = jObject.SelectToken("words_result");
            if (wordsResult != null)
            {
                license.companyName   = wordsResult.SelectToken("单位名称").SelectToken("words").ToString();
                license.expriseDate   = wordsResult.SelectToken("有效期").SelectToken("words").ToString();
                license.licenseNumber = wordsResult.SelectToken("证件编号").SelectToken("words").ToString();
                license.creditNumber  = wordsResult.SelectToken("社会信用代码").SelectToken("words").ToString();
                license.address       = wordsResult.SelectToken("地址").SelectToken("words").ToString();
                license.logalPerson   = wordsResult.SelectToken("法人").SelectToken("words").ToString();
            }
            return(license);
        }
 private void bindingControlValue(BaiduLicenseRecognition recognition)
 {
     mCompany.name                   = recognition.companyName;
     mCompany.legalPerson            = recognition.logalPerson;
     mCompany.liceseEspriseTime      = recognition.expriseDate;
     mCompany.creditNumber           = recognition.creditNumber;
     mCompany.busineseLincenseNumber = recognition.licenseNumber;
     mCompany.address                = recognition.address;
 }
        /// <summary>
        /// Automatic Recognition 开始自动识别
        /// </summary>
        private void AutomaticRecognition()
        {
            string apiKey   = ConfigurationHelper.GetConfig(ConfigItemName.baiduApiKey.ToString());
            string apiScret = ConfigurationHelper.GetConfig(ConfigItemName.baiduApiSecretKey.ToString());
            Ocr    ocr      = new Ocr(apiKey, apiScret);

            Newtonsoft.Json.Linq.JObject ob           = ocr.BusinessLicense(FileHelper.GetBytes(imagePath));
            BaiduLicenseRecognition      baiduLicense = BaiduAipHelper.getLicenseRecognition(ob);

            bindingControlValue(baiduLicense);
        }