using PublicCode.RedisConfig; using System; using System.Collections.Generic; using System.Text; namespace PublicCode.APIModel { #region 百度API请求参数模型 public class BDApiModel { public AccessToken accessToken { get; set; } public ORC ORC { get; set; } } public class AccessToken { /// /// 请求url /// public string RequestUrl { get; set; } /// /// 固定填client_credentials /// public string grant_type { get; set; } /// /// 应用的API Key /// public string client_id { get; set; } /// /// 应用的Secret Key /// public string client_secret { get; set; } } public class ORC { /// /// 请求Url /// public string RequestUrl { get; set; } /// /// 获取到的access_token /// public string access_token { get; set; } /// /// 请求类型application/x-www-form-urlencoded /// public string ContentType { get; set; } /// /// 图像数据,base64编码后进行urlencode, /// 要求base64编码和urlencode后大小不超过4M, /// 最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 /// public string image { get; set; } /// /// 识别语言类型,默认为CHN_ENG,其他请参照下侧附录1 /// public string language_type { get; set; } /// /// 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: ///- true:检测朝向; ///- false:不检测朝向 /// public string detect_direction { get; set; } /// /// 是否输出段落信息 /// public string paragraph { get; set; } /// /// 是否返回识别结果中每一行的置信度 /// public string probability { get; set; } } #endregion #region 百度API返回结果模型 /// /// /// public class OutBDApiModel { /// /// 唯一的log id,用于问题定位 /// public Int64 log_id { get; set; } /// /// 图像方向,当detect_direction=true时存在。 /// - -1:未定义, /// - 0:正向, /// - 1: 逆时针90度, /// - 2:逆时针180度, /// - 3:逆时针270度 /// public Int32 direction { get; set; } /// /// 识别结果数组 /// public Array words_result { get; set; } /// /// 识别结果数,表示words_result的元素个数 /// public UInt32 words_result_num { get; set; } /// /// 识别结果字符串 /// public string _words { get; set; } /// /// 段落检测结果,当 paragraph=true 时返回该字段 /// public Array paragraphs_result { get; set; } /// /// 一个段落包含的行序号,当 paragraph=true 时返回该字段 /// public Array _words_result_idx { get; set; } /// /// 识别结果中每一行的置信度值,包含average:行置信度平均值, /// variance:行置信度方差,min:行置信度最小值 /// public float probability { get; set; } } /// /// access_token实体 /// public class OutAccessToken : IBaseRedisModel { /// /// redisId,参考附录2 /// public string id { get; set; } /// /// 获取到的access_token /// public string access_token { get; set; } /// /// access_token有效果期 /// public string expires_in { get; set; } /// /// 创建时间 /// public string create_time { get; set; } } public class words_result { public Location location { get; set; } public string words { get; set; } } public class Location { public float left { get; set; } public float top { get; set; } public float width { get; set; } public float height { get; set; } } #endregion } #region 附录 #region 附录1 百度识别语言类型 //可选值包括: //-auto_detect:自动检测语言,并识别 //- CHN_ENG:中英文混合 //- ENG:英文 //- JAP:日语 //- KOR:韩语 //- FRE:法语 //- SPA:西班牙语 //- POR:葡萄牙语 //- GER:德语 //- ITA:意大利语 //- RUS:俄语 //- DAN:丹麦语 //- DUT:荷兰语 //- MAL:马来语 //- SWE:瑞典语 //- IND:印尼语 //- POL:波兰语 //- ROM:罗马尼亚语 //- TUR:土耳其语 //- GRE:希腊语 //- HUN:匈牙利语 #endregion #region 附录2 OutAccessToken.id 值参考 //ORC:BDORCAccess_token #endregion #endregion