public static string GeneralBasic(string path) { string resultStr = ""; var client = new Ocr.Ocr(api, key); var image = File.ReadAllBytes(path); // 通用文字识别 var result = client.GeneralBasic(image); //var result = client.Accurate(image); //var result = client.General(image); if (result.Property("words_result") == null || result.Property("words_result").ToString() == "") { Console.WriteLine("键值key不存在!"); return(result.ToString()); } else { var words = result["words_result"]; foreach (var item in words) { resultStr += item["words"]; } } return(resultStr); // 图片url //result = client.GeneralBasic("https://www.baidu.com/img/bd_logo1.png"); }
public static void AccurateWithLocation() { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = File.ReadAllBytes("图片文件路径"); // 高精度识别(带位置信息) var result = client.AccurateWithLocation(image); }
public static void AccurateWithLocation(string path) { var client = new Ocr.Ocr(api, key); var image = File.ReadAllBytes(path); // 高精度识别(带位置信息) //var result = client.AccurateWithLocation(image); }
public static void Accurate(string path) { var client = new Ocr.Ocr(api, key); var image = File.ReadAllBytes(path); // 高精度识别 var result = client.Accurate(image); }
public static void WebImage(string path) { var client = new Ocr.Ocr(api, key); var image = File.ReadAllBytes(path); // 网图识别 var result = client.WebImage(image, null); }
public static void GeneralWithLocatin(string path) { var client = new Ocr.Ocr(api, key); var image = File.ReadAllBytes(path); // 带位置版本 //var result = client.GeneralWithLocatin(image, null); }
public static void BankCard(string path) { var client = new Ocr.Ocr(api, key); var image = File.ReadAllBytes(path); // 银行卡识别 //var result = client.BankCard(image); }
public static void AccurateWithLocation() { var client = new Ocr.Ocr("Api Key", "Secret Key"); var image = File.ReadAllBytes("图片文件路径"); // 高精度识别(带位置信息) var result = client.AccurateWithLocation(image); }
public static void WebImage() { var client = new Ocr.Ocr("Api Key", "Secret Key"); var image = File.ReadAllBytes("图片文件路径"); // 网图识别 var result = client.WebImage(image, null); }
public static void GeneralWithLocatin() { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = File.ReadAllBytes("图片文件路径"); // 带位置版本 var result = client.GeneralWithLocatin(image, null); }
public static void WebImage() { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = File.ReadAllBytes("图片文件路径"); // 网图识别 var result = client.WebImage(image, null); }
/// <summary> /// 基础 /// </summary> /// <param name="tempImage"></param> /// <returns></returns> public static string DrivingLicense(Image tempImage) { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png); var result = client.DrivingLicense(image); return(result.ToString()); }
public static void GeneralEnhanced(string path) { var client = new Ocr.Ocr(api, key); var image = File.ReadAllBytes(path); // 带生僻字版 var result = client.GeneralEnhanced(image); }
public static void BankCard() { var client = new Ocr.Ocr("Api Key", "Secret Key"); var image = File.ReadAllBytes("图片文件路径"); // 银行卡识别 var result = client.BankCard(image); }
public static void GeneralWithLocatin() { var client = new Ocr.Ocr("Api Key", "Secret Key"); var image = File.ReadAllBytes("图片文件路径"); // 带位置版本 var result = client.GeneralWithLocatin(image, null); }
public static void GeneralEnhanced() { var client = new Ocr.Ocr("Api Key", "Secret Key"); var image = File.ReadAllBytes("图片文件路径"); // 带生僻字版 var result = client.GeneralEnhanced(image); }
/// <summary> /// 网络图片识别,适合网络图片文字识别用于识别一些网络上背景复杂,特殊字体的文字。 /// </summary> /// <param name="tempImage"></param> /// <returns>返回 json 字符串</returns> public static string WebImage(Image tempImage) { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png); string result = client.WebImage(image, null).ToString(); return(result); }
public static void GeneralEnhanced() { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = File.ReadAllBytes("图片文件路径"); // 带生僻字版 var result = client.GeneralEnhanced(image); }
public static void BankCard(string imagePath) { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = File.ReadAllBytes(imagePath); // 银行卡识别 var result = client.BankCard(image); }
public static string GeneralEnhanced(Image tempImage) { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png); // 带生僻字版 var result = client.GeneralEnhanced(image); return(result.ToJson()); }
public static void Receipt() { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = File.ReadAllBytes("图片文件路径"); var options = new Dictionary <string, object> { { "recognize_granularity", "small" } // 定位单字符位置 }; var result = client.Receipt(image, options); }
public static void Receipt(string path) { var client = new Ocr.Ocr(api, key); var image = File.ReadAllBytes(path); var options = new Dictionary <string, object> { { "recognize_granularity", "small" } // 定位单字符位置 }; var result = client.Receipt(image, options); }
public static string Accurate(Image tempImage) { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png); // 高精度识别 var result = client.Accurate(image); return(result.ToJson()); }
public static void GeneralBasic() { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = File.ReadAllBytes("图片文件路径"); // 通用文字识别 var result = client.GeneralBasic(image); // 图片url result = client.GeneralBasic("https://www.baidu.com/img/bd_logo1.png"); }
public static void Idcard(string path) { var client = new Ocr.Ocr(api, key); var image = File.ReadAllBytes(path); var options = new Dictionary <string, object> { { "detect_direction", "true" } // 检测方向 }; // 身份证正面识别 //var result = client.IdCardFront(image, options); // 身份证背面识别 //result = client.IdCardBack(image); }
public static void Idcard() { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = File.ReadAllBytes("图片文件路径"); var options = new Dictionary <string, object> { { "detect_direction", "true" } // 检测方向 }; // 身份证正面识别 var result = client.IdCardFront(image, options); // 身份证背面识别 result = client.IdCardBack(image); }
/// <summary> /// 网络图片识别,适合网络图片文字识别用于识别一些网络上背景复杂,特殊字体的文字。 /// </summary> /// <param name="tempImage"></param> public static APIBaseModel <DrivingLicenseModel> GetWebImage(Image tempImage) { APIBaseModel <DrivingLicenseModel> tempModel = new APIBaseModel <DrivingLicenseModel>(); tempModel.contextModel = new DrivingLicenseModel(); var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png); string result = client.WebImage(image, null).ToString(); if (result.Contains("\"error_code\""))//说明异常 { tempModel.state = false; tempModel.contextModel.errorTypeModel = Json.ToObject <ErrorTypeModel>(result); tempModel.errorMsg = tempModel.contextModel.errorTypeModel.error_discription = OCR_CharacterRecognitionErrorType.GetErrorCodeToDescription(tempModel.contextModel.errorTypeModel.error_code); } else { tempModel.state = true; tempModel.contextModel.successModel = Json.ToObject <DrivingLicenseSuessResultModel>(result); } return(tempModel); }
public static void BusinessLicense(string path) { var client = new Ocr.Ocr(api, key); var image = File.ReadAllBytes(path); var result = client.BusinessLicense(image); }
public static void VehicleLicense() { var client = new Ocr.Ocr("Api Key", "Secret Key"); var image = File.ReadAllBytes("图片文件路径"); var result = client.VehicleLicense(image); }
public static void BusinessLicense() { var client = new Ocr.Ocr(Config.clientId, Config.clientSecret); var image = File.ReadAllBytes("图片文件路径"); var result = client.BusinessLicense(image); }