private void driverLicenseRecognition() { Newtonsoft.Json.Linq.JObject ob = getOcr().DrivingLicense(FileHelper.GetBytes(imagePath)); BaiduDriverLicenseRecognition driver = BaiduAipHelper.getDriverRecognition(ob); MessageBox.Show(driver.name); }
public static BaiduDriverLicenseRecognition getDriverRecognition(Newtonsoft.Json.Linq.JObject jObject) { if (jObject == null) { return(null); } BaiduDriverLicenseRecognition driver = new BaiduDriverLicenseRecognition(); Newtonsoft.Json.Linq.JToken jtError = jObject.SelectToken("error_code"); if (jtError != null) { driver.errorCode = jtError.ToString(); driver.ErrorMsg = jObject.SelectToken("error_msg").ToString(); return(driver); } MyHelper.ConsoleHelper.writeLine(jObject.ToString()); Newtonsoft.Json.Linq.JToken wordsResult = jObject.SelectToken("words_result"); if (wordsResult != null) { driver.name = wordsResult.SelectToken("姓名").SelectToken("words").ToString(); driver.number = wordsResult.SelectToken("证号").SelectToken("words").ToString(); try { driver.endTime = wordsResult.SelectToken("至").SelectToken("words").ToString(); driver.startTime = wordsResult.SelectToken("有效期限").SelectToken("words").ToString(); } catch (Exception) { driver.startTime = wordsResult.SelectToken("有效起始日期").SelectToken("words").ToString(); driver.expriseDate = wordsResult.SelectToken("有效期限").SelectToken("words").ToString(); } driver.sex = wordsResult.SelectToken("性别").SelectToken("words").ToString(); driver.birth = wordsResult.SelectToken("出生日期").SelectToken("words").ToString(); driver.country = wordsResult.SelectToken("国籍").SelectToken("words").ToString(); driver.type = wordsResult.SelectToken("准驾车型").SelectToken("words").ToString(); driver.address = wordsResult.SelectToken("住址").SelectToken("words").ToString(); driver.firstDate = wordsResult.SelectToken("初次领证日期").SelectToken("words").ToString(); } return(driver); }