Moli
2022-04-15 22477f0eca904ec628ab59cd749f959af35c1439
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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 {
        /// <summary>
        /// 请求url
        /// </summary>
        public string RequestUrl { get; set; }
        /// <summary>
        /// 固定填client_credentials
        /// </summary>
        public string grant_type { get; set; }
        /// <summary>
        /// 应用的API Key
        /// </summary>
        public string client_id { get; set; }
        /// <summary>
        /// 应用的Secret Key
        /// </summary>
        public string client_secret { get; set; }
    }
 
    public class ORC {
        /// <summary>
        /// 请求Url
        /// </summary>
        public string RequestUrl { get; set; }
        /// <summary>
        /// 获取到的access_token
        /// </summary>
        public string access_token { get; set; }
        /// <summary>
        /// 请求类型application/x-www-form-urlencoded
        /// </summary>
        public string ContentType { get; set; }
        /// <summary>
        /// 图像数据,base64编码后进行urlencode,
        /// 要求base64编码和urlencode后大小不超过4M,
        /// 最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式
        /// </summary>
        public string image { get; set; }
        /// <summary>
        /// 识别语言类型,默认为CHN_ENG,其他请参照下侧附录1
        /// </summary>
        public string language_type { get; set; }
        /// <summary>
        /// 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
        ///- true:检测朝向;
        ///- false:不检测朝向
        /// </summary>
        public string detect_direction { get; set; }
        /// <summary>
        /// 是否输出段落信息
        /// </summary>
        public string paragraph { get; set; }
        /// <summary>
        /// 是否返回识别结果中每一行的置信度
        /// </summary>
        public string probability { get; set; }
    }
    #endregion
 
    #region 百度API返回结果模型
    /// <summary>
    /// 
    /// </summary>
    public class OutBDApiModel {
        /// <summary>
        /// 唯一的log id,用于问题定位
        /// </summary>
        public Int64 log_id { get; set; }
        /// <summary>
        /// 图像方向,当detect_direction=true时存在。
        /// - -1:未定义,
        /// - 0:正向,
        /// - 1: 逆时针90度,
        /// - 2:逆时针180度,
        /// - 3:逆时针270度
        /// </summary>
        public Int32 direction { get; set; }
        /// <summary>
        /// 识别结果数组
        /// </summary>
        public Array words_result { get; set; }
        /// <summary>
        /// 识别结果数,表示words_result的元素个数
        /// </summary>
        public UInt32 words_result_num { get; set; }
        /// <summary>
        /// 识别结果字符串
        /// </summary>
        public string _words { get; set; }
        /// <summary>
        /// 段落检测结果,当 paragraph=true 时返回该字段
        /// </summary>
        public Array paragraphs_result { get; set; }
        /// <summary>
        /// 一个段落包含的行序号,当 paragraph=true 时返回该字段
        /// </summary>
        public Array _words_result_idx { get; set; }
        /// <summary>
        /// 识别结果中每一行的置信度值,包含average:行置信度平均值,
        /// variance:行置信度方差,min:行置信度最小值
        /// </summary>
        public float probability { get; set; }
    }
 
    /// <summary>
    /// access_token实体
    /// </summary>
    public class OutAccessToken : IBaseRedisModel {
        /// <summary>
        /// redisId,参考附录2
        /// </summary>
        public string id { get; set; }
        /// <summary>
        /// 获取到的access_token
        /// </summary>
        public string access_token { get; set; }
        /// <summary>
        /// access_token有效果期
        /// </summary>
        public string expires_in { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        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