diff --git a/1.txt b/1.txt new file mode 100644 index 0000000..0cee270 --- /dev/null +++ b/1.txt @@ -0,0 +1 @@ +3213 \ No newline at end of file diff --git a/Application_Enter.py b/Application_Enter.py new file mode 100644 index 0000000..637230b --- /dev/null +++ b/Application_Enter.py @@ -0,0 +1,258 @@ +from openpyxl import load_workbook +from openpyxl.styles import * +import time +import warnings +warnings.filterwarnings('ignore') + +#判断是否在校 +#此处为入校申请 +def inschool (u,a): + wb = load_workbook('Student.xlsx') + ws = wb.active + u_inschool = u+1 + state = ws.cell(row=u_inschool, column=3).value + + if state == 'y' and a == 1: + print("您已在学校,不能提交入校申请") + #在校状态不能申请入校 + elif state == 'n' and a == 1: + print("您可以正常申请入校") + #离校状态可以正常申请入校 + return 1 + +#填写表格 +def write_form (a,c,p): + print("=============================================") + print("开始填表") + #申请类型 + application = int(a) + + #姓名 + name = input("请输入姓名:") + + #学号 + id = input("请输入学号:") + + #联系电话 + phone = input("请输入联系电话:") + + #时间 + Time = '' + while Time == '': + t1 = input("请输入入校时间(格式样例:2022-07-22 23:00:00)(要求为当日且不能早于6点晚于22点):") + # t1 = str('2022-10-23 21:00:00') + Time = str(time_judge(t1)) + + #校门 + door = '' + while door == '': + d = int(input("请选择校门(1.东门 2.南门 3.西门 4.北门):")) + door = door_choice(d) + + #以下为前端数据,此处用输入代替 + #地址 + province = input("请输入省市:") + district = input("请输入区:") + place = input("请输入详细地址:") + + #健康码 + health_code = '' + while health_code == '': + h = str(input("请输入健康码状态(绿/黄/红):")) + health_code = health_code_judge(h) + + #行程码 + Tour_code = input("请输入行程码状态:") + + #核酸 + NAT = '' + while NAT == '': + n = str(input("请输入核酸状态(阴/阳):")) + NAT = NAT_judge(n) + + #申请状态 + application_count = int(c + 1) + + #通过状态 + Pass = int(p) + + #提交确认 + submit = Submit(name,id,phone,Time,door,province,district,place,health_code,Tour_code,NAT) + if submit == 'n': + print("填写取消,返回上级菜单") + return 0 + + #封装 + data = data_set(application,name,id,phone,Time,door,province,district,place,health_code,Tour_code,NAT,application_count,Pass) + #print(data) + + #写入excel + write(data) + + #调整excel格式 + style('Form.xlsx') + +#判断时间合理性 +def time_judge(t11): + t1 = time.strptime(t11, "%Y-%m-%d %H:%M:%S") + t = time.localtime() + year = str(t.tm_year) + mon = str(t.tm_mon) + day2 = str(t.tm_mday) + hour = str(t.tm_hour) + minute = str(t.tm_min) + sec = str(t.tm_sec) + t22 = str(year + '-' + mon + '-' + day2 + ' ' + hour + ':' + minute + ':' + sec) + t2 = time.strptime(t22, "%Y-%m-%d %H:%M:%S") + + #判断填写时间是否比当前时间早 + tl = (time.mktime(t1)-time.mktime(t2)) + if tl <= 0: + print("请输入比当前时间晚的时间") + return '' + + #判断日期是否为当日 + day1 = str(t1.tm_mday) + if day1 != day2: + print("申请只能为当日") + return '' + + hour1 = t1.tm_hour + minute1 = t1.tm_min + sec1 = t1.tm_sec + + #判断申请时间是否晚于6点 + if hour1 < 6: + print("入校必须晚于6点!") + return '' + + #判断申请时间是否早于10点 + if hour1 > 22: + print("入校必须早于22点!") + return '' + elif hour1 == 22 and minute1 != 0 and sec1 != 0: + print("入校必须早于22点!") + return '' + + return t11 + +#选择校门 +def door_choice(d): + if d == 1: + return 'East' + elif d == 2: + return 'South' + elif d == 3: + return 'West' + elif d == 4: + return 'North' + else: + print("请选择正确的校门!") + return '' + +#判断健康码信息填写正确性 +def health_code_judge(h): + if h != "绿" and h != "黄" and h != "红": + print("请输入正确的健康码信息") + return '' + else: + return h + +#判断核酸信息填写正确性 +def NAT_judge(n): + if n != "阴" and n != "阳": + print("请输入正确的核酸信息") + return '' + else: + return n + +#提交确认 +def Submit(name,id,phone,Time,door,province,district,place,health_code,Tour_code,NAT): + print("=============================================") + print("申请类型为:入校申请") + print("姓名:" + name) + print("学号:" + id) + print("联系电话:" + phone) + print("时间:" + Time) + print("校门:" + door) + print("省市:" + province) + print("区:" + district) + print("详细地址:" + place) + print("健康码信息:" + health_code) + print("行程码信息:" + Tour_code) + print("核酸:" + NAT) + print("申请状态:待审核") + print("通过状态:待审核") + submit = input("以上为填写信息,是否提交(y/n)") + return submit + +#数据封装 +def data_set(application,name,id,phone,time,door,province,district,place,health_code,Tour_code,NAT,application_count,Pass): + data_form = { + "application": application, + "name": name, + "id": id, + "phone": phone, + "time": time, + "door": door, + "province": province, + "district": district, + "place": place, + "health_code": health_code, + "Tour_code": Tour_code, + "NAT": NAT, + "application_count": application_count, + "Pass": Pass + } + return data_form + +#数据写入excel +def write(data): + wb = load_workbook('Form.xlsx') + ws = wb.active + d = ( + data["application"], + data["name"], + data["id"], + data["phone"], + data["time"], + data["door"], + data["province"], + data["district"], + data["place"], + data["health_code"], + data["Tour_code"], + data["NAT"], + data["application_count"], + data["Pass"] + ) + ws.append(d) + wb.save('Form.xlsx') + print("提交成功!") + +#调整excel格式 +def style(file): + wb = load_workbook(file) + ws = wb.active + for row in ws.iter_rows(): + for cell in row: + if cell is not None: + cell.alignment = Alignment(horizontal='center',vertical='center') + wb.save(file) + +#代码运行主体 +x = 1 +while x: + user = int(input("请选择用户(1.张三 2.李四 3.王五):")) + print("您选择的是入校申请") + #申请类型:1为入校申请 2为出校申请 此处默认为1 + application = 1 + #申请状态(0无1有) + application_count = 0 + #通过状态默认为0 + Pass = 0 + if inschool(user,application): + write_form(application,application_count,Pass) + x = 0 + else: + print("请返回上级菜单,提交申请请选择出校申请") \ No newline at end of file diff --git a/Form.xlsx b/Form.xlsx new file mode 100644 index 0000000..b7b04a3 Binary files /dev/null and b/Form.xlsx differ diff --git a/Student.xlsx b/Student.xlsx new file mode 100644 index 0000000..e70bf94 Binary files /dev/null and b/Student.xlsx differ diff --git a/TEST.Database.sql b/TEST.Database.sql new file mode 100644 index 0000000..5c07171 Binary files /dev/null and b/TEST.Database.sql differ diff --git a/dbo.Course.Table.sql b/dbo.Course.Table.sql new file mode 100644 index 0000000..d616415 Binary files /dev/null and b/dbo.Course.Table.sql differ diff --git a/dbo.SC.Table.sql b/dbo.SC.Table.sql new file mode 100644 index 0000000..59b4d7e Binary files /dev/null and b/dbo.SC.Table.sql differ diff --git a/dbo.Student.Table.sql b/dbo.Student.Table.sql new file mode 100644 index 0000000..e198cc9 Binary files /dev/null and b/dbo.Student.Table.sql differ diff --git a/model/常态化大学生出入校管理系统界面流的顺序图.png b/model/常态化大学生出入校管理系统界面流的顺序图.png new file mode 100644 index 0000000..782c840 Binary files /dev/null and b/model/常态化大学生出入校管理系统界面流的顺序图.png differ diff --git a/model/常态化大学生出入校管理系统界面类表示:首页.png b/model/常态化大学生出入校管理系统界面类表示:首页.png new file mode 100644 index 0000000..5d0fe22 Binary files /dev/null and b/model/常态化大学生出入校管理系统界面类表示:首页.png differ diff --git a/model/常态化疫情下的大学生出入校管理系统“入校申请”用例的顺序图.vsdx b/model/常态化疫情下的大学生出入校管理系统“入校申请”用例的顺序图.vsdx deleted file mode 100644 index 284b362..0000000 Binary files a/model/常态化疫情下的大学生出入校管理系统“入校申请”用例的顺序图.vsdx and /dev/null differ diff --git a/model/常态化疫情下的大学生出入校管理系统“出校申请”用例的顺序图.vsdx b/model/常态化疫情下的大学生出入校管理系统“出校申请”用例的顺序图.vsdx deleted file mode 100644 index a6c882c..0000000 Binary files a/model/常态化疫情下的大学生出入校管理系统“出校申请”用例的顺序图.vsdx and /dev/null differ diff --git a/model/常态化疫情下的大学生出入校管理系统“定时器权限”用例设计顺序图.vsdx b/model/常态化疫情下的大学生出入校管理系统“定时器权限”用例设计顺序图.vsdx new file mode 100644 index 0000000..258f6e3 Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统“定时器权限”用例设计顺序图.vsdx differ diff --git a/model/常态化疫情下的大学生出入校管理系统“扫码”用例的顺序图.vsdx b/model/常态化疫情下的大学生出入校管理系统“手动审批”用例的顺序图.vsdx similarity index 50% rename from model/常态化疫情下的大学生出入校管理系统“扫码”用例的顺序图.vsdx rename to model/常态化疫情下的大学生出入校管理系统“手动审批”用例的顺序图.vsdx index 33cf2fa..84305ce 100644 Binary files a/model/常态化疫情下的大学生出入校管理系统“扫码”用例的顺序图.vsdx and b/model/常态化疫情下的大学生出入校管理系统“手动审批”用例的顺序图.vsdx differ diff --git a/model/常态化疫情下的大学生出入校管理系统“状态查询”用例的顺序图.vsdx b/model/常态化疫情下的大学生出入校管理系统“状态查询”用例的顺序图.vsdx new file mode 100644 index 0000000..ae402fc Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统“状态查询”用例的顺序图.vsdx differ diff --git a/model/常态化疫情下的大学生出入校管理系统“用户权限”用例设计顺序图.vsdx b/model/常态化疫情下的大学生出入校管理系统“用户权限”用例设计顺序图.vsdx new file mode 100644 index 0000000..426866d Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统“用户权限”用例设计顺序图.vsdx differ diff --git a/model/常态化疫情下的大学生出入校管理系统“更新疫情信息”用例的顺序图.vsdx b/model/常态化疫情下的大学生出入校管理系统“疫情信息”用例的顺序图.vsdx similarity index 56% rename from model/常态化疫情下的大学生出入校管理系统“更新疫情信息”用例的顺序图.vsdx rename to model/常态化疫情下的大学生出入校管理系统“疫情信息”用例的顺序图.vsdx index 166bad0..549b623 100644 Binary files a/model/常态化疫情下的大学生出入校管理系统“更新疫情信息”用例的顺序图.vsdx and b/model/常态化疫情下的大学生出入校管理系统“疫情信息”用例的顺序图.vsdx differ diff --git a/model/常态化疫情下的大学生出入校管理系统“管理员权限”用例设计顺序图.vsdx b/model/常态化疫情下的大学生出入校管理系统“管理员权限”用例设计顺序图.vsdx new file mode 100644 index 0000000..d4a8ad6 Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统“管理员权限”用例设计顺序图.vsdx differ diff --git a/model/常态化疫情下的大学生出入校管理系统“身份验证”用例的顺序图.vsdx b/model/常态化疫情下的大学生出入校管理系统“身份验证”用例的顺序图.vsdx new file mode 100644 index 0000000..b68a33a Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统“身份验证”用例的顺序图.vsdx differ diff --git a/model/常态化疫情下的大学生出入校管理系统体系结构逻辑视图.vsdx b/model/常态化疫情下的大学生出入校管理系统体系结构逻辑视图.vsdx new file mode 100644 index 0000000..b6b2b49 Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统体系结构逻辑视图.vsdx differ diff --git a/model/常态化疫情下的大学生出入校管理系统分析类图.png b/model/常态化疫情下的大学生出入校管理系统分析类图.png new file mode 100644 index 0000000..c841c64 Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统分析类图.png differ diff --git a/model/常态化疫情下的大学生出入校管理系统数据设计类图.vsdx b/model/常态化疫情下的大学生出入校管理系统数据设计类图.vsdx new file mode 100644 index 0000000..aed41e7 Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统数据设计类图.vsdx differ diff --git a/model/常态化疫情下的大学生出入校管理系统用例模型.vsdx b/model/常态化疫情下的大学生出入校管理系统用例模型.vsdx new file mode 100644 index 0000000..4b455fc Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统用例模型.vsdx differ diff --git a/model/常态化疫情下的大学生出入校管理系统界面类表示:用户主页面.png b/model/常态化疫情下的大学生出入校管理系统界面类表示:用户主页面.png new file mode 100644 index 0000000..ec3ee30 Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统界面类表示:用户主页面.png differ diff --git a/model/常态化疫情下的大学生出入校管理系统界面类表示:用户登录.png b/model/常态化疫情下的大学生出入校管理系统界面类表示:用户登录.png new file mode 100644 index 0000000..0698c78 Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统界面类表示:用户登录.png differ diff --git a/model/常态化疫情下的大学生出入校管理系统界面类表示:管理员主页面.png b/model/常态化疫情下的大学生出入校管理系统界面类表示:管理员主页面.png new file mode 100644 index 0000000..863abf5 Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统界面类表示:管理员主页面.png differ diff --git a/model/常态化疫情下的大学生出入校管理系统界面类表示:管理员登录.png b/model/常态化疫情下的大学生出入校管理系统界面类表示:管理员登录.png new file mode 100644 index 0000000..bd57782 Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统界面类表示:管理员登录.png differ diff --git a/model/常态化疫情下的大学生出入校管理系统设计类图.png b/model/常态化疫情下的大学生出入校管理系统设计类图.png new file mode 100644 index 0000000..61c7946 Binary files /dev/null and b/model/常态化疫情下的大学生出入校管理系统设计类图.png differ diff --git a/src/OCR_baidu.jar b/src/OCR_baidu.jar new file mode 100644 index 0000000..b997942 Binary files /dev/null and b/src/OCR_baidu.jar differ diff --git a/src/OCR_baidu/.idea/.gitignore b/src/OCR_baidu/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/src/OCR_baidu/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/src/OCR_baidu/.idea/artifacts/OCR_baidu_jar.xml b/src/OCR_baidu/.idea/artifacts/OCR_baidu_jar.xml new file mode 100644 index 0000000..89136c5 --- /dev/null +++ b/src/OCR_baidu/.idea/artifacts/OCR_baidu_jar.xml @@ -0,0 +1,12 @@ + + + $PROJECT_DIR$/out/artifacts/OCR_baidu_jar + + + + + + + + + \ No newline at end of file diff --git a/src/OCR_baidu/.idea/compiler.xml b/src/OCR_baidu/.idea/compiler.xml new file mode 100644 index 0000000..a1757ae --- /dev/null +++ b/src/OCR_baidu/.idea/compiler.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/OCR_baidu/.idea/libraries/aip_java_sdk_4_16_11.xml b/src/OCR_baidu/.idea/libraries/aip_java_sdk_4_16_11.xml new file mode 100644 index 0000000..6052cd7 --- /dev/null +++ b/src/OCR_baidu/.idea/libraries/aip_java_sdk_4_16_11.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/OCR_baidu/.idea/libraries/json_20160810.xml b/src/OCR_baidu/.idea/libraries/json_20160810.xml new file mode 100644 index 0000000..fc37fb4 --- /dev/null +++ b/src/OCR_baidu/.idea/libraries/json_20160810.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/OCR_baidu/.idea/libraries/slf4j_api_1_7_25.xml b/src/OCR_baidu/.idea/libraries/slf4j_api_1_7_25.xml new file mode 100644 index 0000000..72c9c27 --- /dev/null +++ b/src/OCR_baidu/.idea/libraries/slf4j_api_1_7_25.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/OCR_baidu/.idea/libraries/slf4j_simple_1_7_25.xml b/src/OCR_baidu/.idea/libraries/slf4j_simple_1_7_25.xml new file mode 100644 index 0000000..b804740 --- /dev/null +++ b/src/OCR_baidu/.idea/libraries/slf4j_simple_1_7_25.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/OCR_baidu/.idea/misc.xml b/src/OCR_baidu/.idea/misc.xml new file mode 100644 index 0000000..f76f386 --- /dev/null +++ b/src/OCR_baidu/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/src/OCR_baidu/.idea/modules.xml b/src/OCR_baidu/.idea/modules.xml new file mode 100644 index 0000000..b39853e --- /dev/null +++ b/src/OCR_baidu/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/OCR_baidu/.idea/uiDesigner.xml b/src/OCR_baidu/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/src/OCR_baidu/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/OCR_baidu/META-INF/MANIFEST.MF b/src/OCR_baidu/META-INF/MANIFEST.MF new file mode 100644 index 0000000..9b8fcba --- /dev/null +++ b/src/OCR_baidu/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: OCR + diff --git a/src/OCR_baidu/OCR_baidu.iml b/src/OCR_baidu/OCR_baidu.iml new file mode 100644 index 0000000..025727a --- /dev/null +++ b/src/OCR_baidu/OCR_baidu.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/OCR_baidu/lib/aip-java-sdk-4.16.11.jar b/src/OCR_baidu/lib/aip-java-sdk-4.16.11.jar new file mode 100644 index 0000000..1fe3884 Binary files /dev/null and b/src/OCR_baidu/lib/aip-java-sdk-4.16.11.jar differ diff --git a/src/OCR_baidu/lib/json-20160810.jar b/src/OCR_baidu/lib/json-20160810.jar new file mode 100644 index 0000000..a90e448 Binary files /dev/null and b/src/OCR_baidu/lib/json-20160810.jar differ diff --git a/src/OCR_baidu/lib/slf4j-api-1.7.25.jar b/src/OCR_baidu/lib/slf4j-api-1.7.25.jar new file mode 100644 index 0000000..0143c09 Binary files /dev/null and b/src/OCR_baidu/lib/slf4j-api-1.7.25.jar differ diff --git a/src/OCR_baidu/lib/slf4j-simple-1.7.25.jar b/src/OCR_baidu/lib/slf4j-simple-1.7.25.jar new file mode 100644 index 0000000..a7260f3 Binary files /dev/null and b/src/OCR_baidu/lib/slf4j-simple-1.7.25.jar differ diff --git a/src/OCR_baidu/out/META-INF/MANIFEST.MF b/src/OCR_baidu/out/META-INF/MANIFEST.MF new file mode 100644 index 0000000..a30bfa7 --- /dev/null +++ b/src/OCR_baidu/out/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: HealthCode + diff --git a/src/OCR_baidu/out/production/OCR_baidu/AipOcr.class b/src/OCR_baidu/out/production/OCR_baidu/AipOcr.class new file mode 100644 index 0000000..9cfd8dc Binary files /dev/null and b/src/OCR_baidu/out/production/OCR_baidu/AipOcr.class differ diff --git a/src/OCR_baidu/out/production/OCR_baidu/CovidTestRep.class b/src/OCR_baidu/out/production/OCR_baidu/CovidTestRep.class new file mode 100644 index 0000000..4253a2d Binary files /dev/null and b/src/OCR_baidu/out/production/OCR_baidu/CovidTestRep.class differ diff --git a/src/OCR_baidu/out/production/OCR_baidu/HealthCode.class b/src/OCR_baidu/out/production/OCR_baidu/HealthCode.class new file mode 100644 index 0000000..74a26f1 Binary files /dev/null and b/src/OCR_baidu/out/production/OCR_baidu/HealthCode.class differ diff --git a/src/OCR_baidu/out/production/OCR_baidu/META-INF/MANIFEST.MF b/src/OCR_baidu/out/production/OCR_baidu/META-INF/MANIFEST.MF new file mode 100644 index 0000000..a30bfa7 --- /dev/null +++ b/src/OCR_baidu/out/production/OCR_baidu/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: HealthCode + diff --git a/src/OCR_baidu/out/production/OCR_baidu/TripCode.class b/src/OCR_baidu/out/production/OCR_baidu/TripCode.class new file mode 100644 index 0000000..c207233 Binary files /dev/null and b/src/OCR_baidu/out/production/OCR_baidu/TripCode.class differ diff --git a/src/OCR_baidu/src/AipOcr.java b/src/OCR_baidu/src/AipOcr.java new file mode 100644 index 0000000..262f815 --- /dev/null +++ b/src/OCR_baidu/src/AipOcr.java @@ -0,0 +1,1841 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +import com.baidu.aip.client.BaseClient; +import com.baidu.aip.contentcensor.EImgType; +import com.baidu.aip.error.AipError; +import com.baidu.aip.http.AipRequest; +import com.baidu.aip.util.Base64Util; +import com.baidu.aip.util.Util; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.Calendar; +import java.util.HashMap; + +public class AipOcr extends BaseClient { + public AipOcr(String appId, String apiKey, String secretKey) { + super(appId, apiKey, secretKey); + } + + public JSONObject basicGeneral(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject basicGeneral(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.basicGeneral(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject basicGeneralUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject basicAccurateGeneral(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject basicAccurateGeneral(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.basicAccurateGeneral(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject general(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/general"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject general(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.general(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject generalUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/general"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject accurateGeneral(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/accurate"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject accurateGeneral(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.accurateGeneral(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject enhancedGeneral(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/general_enhanced"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject enhancedGeneral(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.enhancedGeneral(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject enhancedGeneralUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/general_enhanced"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject webImage(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/webimage"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject webImage(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.webImage(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject webImageUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/webimage"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject idcard(byte[] image, String idCardSide, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + request.addBody("id_card_side", idCardSide); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/idcard"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject idcard(String image, String idCardSide, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.idcard(data, idCardSide, options); + } catch (IOException var5) { + var5.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject bankcard(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/bankcard"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject bankcard(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.bankcard(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject drivingLicense(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/driving_license"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject drivingLicense(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.drivingLicense(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject vehicleLicense(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_license"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vehicleLicense(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.vehicleLicense(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject plateLicense(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject plateLicense(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.plateLicense(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject businessLicense(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/business_license"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject businessLicense(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.businessLicense(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject receipt(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/receipt"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject receipt(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.receipt(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject trainTicket(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/train_ticket"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject trainTicket(String image, EImgType type, HashMap options) { + return this.ocrByUrlOrFile(image, type, "https://aip.baidubce.com/rest/2.0/ocr/v1/train_ticket", options); + } + + public JSONObject taxiReceipt(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/taxi_receipt"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject taxiReceipt(String image, EImgType type, HashMap options) { + return this.ocrByUrlOrFile(image, type, "https://aip.baidubce.com/rest/2.0/ocr/v1/taxi_receipt", options); + } + + public JSONObject form(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/form"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject form(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.form(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject tableRecognitionAsync(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/solution/v1/form_ocr/request"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject tableRecognitionAsync(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.tableRecognitionAsync(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject tableResultGet(String requestId, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("request_id", requestId); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/solution/v1/form_ocr/get_request_result"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vinCode(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vin_code"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vinCode(String image, EImgType type, HashMap options) { + return this.ocrByUrlOrFile(image, type, "https://aip.baidubce.com/rest/2.0/ocr/v1/vin_code", options); + } + + public JSONObject quotaInvoice(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/quota_invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject quotaInvoice(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.quotaInvoice(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject householdRegister(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/household_register"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject householdRegister(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.householdRegister(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject HKMacauExitentrypermit(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/HK_Macau_exitentrypermit"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject HKMacauExitentrypermit(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.HKMacauExitentrypermit(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject taiwanExitentrypermit(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/taiwan_exitentrypermit"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject taiwanExitentrypermit(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.taiwanExitentrypermit(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject birthCertificate(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/birth_certificate"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject birthCertificate(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.birthCertificate(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject vehicleInvoice(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vehicleInvoice(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.vehicleInvoice(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject vehicleCertificate(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_certificate"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vehicleCertificate(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.vehicleCertificate(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject invoice(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject invoice(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.invoice(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject airTicket(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/air_ticket"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject airTicket(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.airTicket(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject insuranceDocuments(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/insurance_documents"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject insuranceDocuments(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.insuranceDocuments(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject vatInvoice(String image, EImgType type, HashMap options) { + if (type == EImgType.PDF) { + AipRequest request = new AipRequest(); + this.preOperation(request); + if (options != null) { + request.addBody(options); + } + + try { + byte[] data = Util.readFileByBytes(image); + String base64Content = Base64Util.encode(data); + request.addBody("pdf_file", base64Content); + } catch (IOException var7) { + var7.printStackTrace(); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice"); + this.postOperation(request); + return this.requestServer(request); + } else { + return this.ocrByUrlOrFile(image, type, "https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice", options); + } + } + + public JSONObject vatInvoice(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vatInvoice(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.vatInvoice(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject qrcode(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/qrcode"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject qrcode(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.qrcode(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject numbers(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/numbers"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject numbers(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.numbers(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject lottery(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/lottery"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject lottery(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.lottery(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject passport(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/passport"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject passport(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.passport(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject businessCard(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/business_card"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject businessCard(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.businessCard(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject handwriting(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/handwriting"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject handwriting(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.handwriting(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject custom(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/solution/v1/iocr/recognise"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject custom(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.custom(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject getTableRecognitionJsonResult(String requestId) { + return this.getTableResultHelper(requestId, "json"); + } + + public JSONObject getTableRecognitionExcelResult(String requestId) { + return this.getTableResultHelper(requestId, "excel"); + } + + private JSONObject getTableResultHelper(String requestId, String resultType) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("request_id", requestId); + request.addBody("result_type", resultType); + request.setUri("https://aip.baidubce.com/rest/2.0/solution/v1/form_ocr/get_request_result"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject tableRecognizeToJson(String imgPath, long timeoutMiliseconds) { + try { + byte[] imgData = Util.readFileByBytes(imgPath); + return this.tableRecognizeToJson(imgData, timeoutMiliseconds); + } catch (IOException var5) { + var5.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject tableRecognizeToJson(byte[] imgData, long timeoutMiliseconds) { + return this.tableRecSyncHelper(imgData, timeoutMiliseconds, "json"); + } + + public JSONObject tableRecognizeToExcelUrl(String imgPath, long timeoutMiliseconds) { + try { + byte[] imgData = Util.readFileByBytes(imgPath); + return this.tableRecognizeToExcelUrl(imgData, timeoutMiliseconds); + } catch (IOException var5) { + var5.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject tableRecognizeToExcelUrl(byte[] imgData, long timeoutMiliseconds) { + return this.tableRecSyncHelper(imgData, timeoutMiliseconds, "excel"); + } + + private JSONObject tableRecSyncHelper(byte[] imgData, long timeout, String resultType) { + JSONObject res = this.tableRecognitionAsync((byte[])imgData, (HashMap)null); + if (res.has("error_code")) { + return res; + } else { + String reqId = res.getJSONArray("result").getJSONObject(0).getString("request_id"); + long start = Calendar.getInstance().getTimeInMillis(); + long sleepInterval = 2000L; + + while(true) { + long now = Calendar.getInstance().getTimeInMillis(); + if (now - start > timeout) { + return AipError.ASYNC_TIMEOUT_ERROR.toJsonResult(); + } + + JSONObject result = this.getTableResultHelper(reqId, resultType); + if (result.has("error_code")) { + return result; + } + + int retCode = result.getJSONObject("result").getInt("ret_code"); + if (retCode == 3) { + return result; + } + + try { + Thread.sleep(sleepInterval); + } catch (InterruptedException var16) { + var16.printStackTrace(); + } + } + } + } + + public JSONObject docAnalysis(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.docAnalysis(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject docAnalysis(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/doc_analysis"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject meter(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.meter(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject meter(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/meter"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject webimageLoc(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.webimageLoc(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject webimageLoc(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/webimage_loc"); + this.postOperation(request); + return this.requestServer(request); + } + + private JSONObject ocrByUrlOrFile(String image, EImgType type, String targetUrl, HashMap options) { + return type == EImgType.FILE ? this.ocrByFile(image, targetUrl, options) : this.ocrByUrl(image, targetUrl, options); + } + + private JSONObject ocrByUrl(String imageUrl, String targetUrl, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", imageUrl); + if (options != null) { + request.addBody(options); + } + + request.setUri(targetUrl); + this.postOperation(request); + return this.requestServer(request); + } + + private JSONObject ocrByFile(String image, String targetUrl, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + + try { + byte[] data = Util.readFileByBytes(image); + String base64Content = Base64Util.encode(data); + request.addBody("image", base64Content); + } catch (IOException var7) { + var7.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + + if (options != null) { + request.addBody(options); + } + + request.setUri(targetUrl); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject qrcodeUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/qrcode"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject docAnalysisUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/doc_analysis"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vehicleInvoiceUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vehicleCertificateUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_certificate"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject householdRegisterUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/household_register"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject handwritingUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/handwriting"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject airTicketUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/air_ticket"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject invoiceUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject passportUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/passport"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject onlineTaxiItinerary(byte[] image) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/online_taxi_itinerary"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject onlineTaxiItineraryUrl(String url) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/online_taxi_itinerary"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject onlineTaxiItineraryPdf(byte[] pdfFile, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(pdfFile); + request.addBody("pdf_file", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/online_taxi_itinerary"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject weightNote(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/weight_note"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject weightNoteUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/weight_note"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject weightNotePdf(byte[] pdfFile, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(pdfFile); + request.addBody("pdf_file", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/weight_note"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject medicalDetail(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/medical_detail"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject medicalDetailUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/medical_detail"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject docAnalysisOffice(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.docAnalysisOffice(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject docAnalysisOffice(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/doc_analysis_office"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject docAnalysisOfficeUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/doc_analysis_office"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject docAnalysisOfficePdf(String pdf, int pdfFileNum, HashMap options) { + try { + byte[] data = Util.readFileByBytes(pdf); + return this.docAnalysisOfficePdf(data, pdfFileNum, options); + } catch (IOException var5) { + var5.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject docAnalysisOfficePdf(byte[] pdf, int pdfFileNum, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(pdf); + request.addBody("pdf_file", base64Content); + request.addBody("pdf_file_num", pdfFileNum); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/doc_analysis_office"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject seal(String image) { + try { + byte[] data = Util.readFileByBytes(image); + return this.seal(data); + } catch (IOException var3) { + var3.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject seal(byte[] image) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/seal"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject sealUrl(String url) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/seal"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject sealPdf(String pdf, int pdfFileNum) { + try { + byte[] data = Util.readFileByBytes(pdf); + return this.sealPdf(data, pdfFileNum); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject sealPdf(byte[] pdf, int pdfFileNum) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(pdf); + request.addBody("pdf_file", base64Content); + request.addBody("pdf_file_num", pdfFileNum); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/seal"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject multiIdcard(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.multiIdcard(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject multiIdcard(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/multi_idcard"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject multiIdcardUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/multi_idcard"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject mixedMultiVehicle(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.mixedMultiVehicle(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject mixedMultiVehicle(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/mixed_multi_vehicle"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject mixedMultiVehicleUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/mixed_multi_vehicle"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vehicleRegistrationCertificate(String image) { + try { + byte[] data = Util.readFileByBytes(image); + return this.vehicleRegistrationCertificate(data); + } catch (IOException var3) { + var3.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject vehicleRegistrationCertificate(byte[] image) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_registration_certificate"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vehicleRegistrationCertificateUrl(String url) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_registration_certificate"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject multipleInvoice(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.multipleInvoice(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject multipleInvoice(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/multiple_invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject multipleInvoiceUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/multiple_invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject multipleInvoicePdf(String pdf, int pdfFileNum, HashMap options) { + try { + byte[] data = Util.readFileByBytes(pdf); + return this.multipleInvoicePdf(data, pdfFileNum, options); + } catch (IOException var5) { + var5.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject multipleInvoicePdf(byte[] pdf, int pdfFileNum, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(pdf); + request.addBody("pdf_file", base64Content); + request.addBody("pdf_file_num", pdfFileNum); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/multiple_invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject vatInvoiceVerification(String invoiceCode, String invoiceNum, String invoiceDate, String invoiceType, String checkCode, String totalAmount) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("invoice_code", invoiceCode); + request.addBody("invoice_num", invoiceNum); + request.addBody("invoice_date", invoiceDate); + request.addBody("invoice_type", invoiceType); + request.addBody("check_code", checkCode); + request.addBody("total_amount", totalAmount); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice_verification"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject busTicket(String image) { + try { + byte[] data = Util.readFileByBytes(image); + return this.busTicket(data); + } catch (IOException var3) { + var3.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject busTicket(byte[] image) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/bus_ticket"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject busTicketUrl(String url) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/bus_ticket"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject medicalInvoice(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.medicalInvoice(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject medicalInvoice(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/medical_invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject medicalInvoiceUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/medical_invoice"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject formula(String image, HashMap options) { + try { + byte[] data = Util.readFileByBytes(image); + return this.formula(data, options); + } catch (IOException var4) { + var4.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject formula(byte[] image, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/formula"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject formulaUrl(String url, HashMap options) { + AipRequest request = new AipRequest(); + this.preOperation(request); + request.addBody("url", url); + if (options != null) { + request.addBody(options); + } + + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/formula"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject travelCard(String image) { + try { + byte[] data = Util.readFileByBytes(image); + return this.travelCard(data); + } catch (IOException var3) { + var3.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject travelCard(byte[] image) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/travel_card"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject facade(String image) { + try { + byte[] data = Util.readFileByBytes(image); + return this.facade(data); + } catch (IOException var3) { + var3.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject facade(byte[] image) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/facade"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject healthCode(String image) { + try { + byte[] data = Util.readFileByBytes(image); + return this.healthCode(data); + } catch (IOException var3) { + var3.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject healthCode(byte[] image) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/health_code"); + this.postOperation(request); + return this.requestServer(request); + } + + public JSONObject covidTest(String image) { + try { + byte[] data = Util.readFileByBytes(image); + return this.covidTest(data); + } catch (IOException var3) { + var3.printStackTrace(); + return AipError.IMAGE_READ_ERROR.toJsonResult(); + } + } + + public JSONObject covidTest(byte[] image) { + AipRequest request = new AipRequest(); + this.preOperation(request); + String base64Content = Base64Util.encode(image); + request.addBody("image", base64Content); + request.setUri("https://aip.baidubce.com/rest/2.0/ocr/v1/covid_test"); + this.postOperation(request); + return this.requestServer(request); + } +} diff --git a/src/OCR_baidu/src/CovidTestRep.java b/src/OCR_baidu/src/CovidTestRep.java new file mode 100644 index 0000000..61e8a9e --- /dev/null +++ b/src/OCR_baidu/src/CovidTestRep.java @@ -0,0 +1,138 @@ +import com.baidu.aip.ocr.AipOcr; +import org.json.JSONObject; + +import java.util.HashMap; + +public class CovidTestRep { + private String Name; + private String Time; + private String Status; + public CovidTestRep() { + Name = ""; + Time = ""; + Status = ""; + } + + public String getName() { + return Name; + } + + public String getData() { + return Time; + } + + public String getStatus() { + return Status; + } + + public void setStatus(String status) { + Status = status; + } + + public void setName(String name) { + Name = name; + } + + public void setData(String data) { + Time = data; + } + + public void Print() { + System.out.println("Name:" + this.Name); + System.out.println("Data:" + this.Time); + System.out.println("Status:" + this.Status); + } + + + public static void main(String[] args) { + String path = "C:/Users//16491/eclipse-workspace/OCR_baidu/src/3.jpg";// 初始化一个AipOcr + ocr3(path); + } + public static String Judge(String path) { + CovidTestRep Ctr=new CovidTestRep(); + Ctr=ocr3(path); + String StatusNameTime=Ctr.Status+","+Ctr.Name+","+Ctr.Time; + return StatusNameTime; + } + public static CovidTestRep ocr3(String path) { + final String APP_ID = "28049220"; + final String API_KEY = "qyKlUy6xSapA89DTPomExteq"; + final String SECRET_KEY = "q5EYpXULVh5gC3firLU1nGaymwIwOMBd"; + AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY); + + // 可选:设置网络连接参数 + client.setConnectionTimeoutInMillis(2000); + client.setSocketTimeoutInMillis(10000); + + // 可选:设置代理服务器地址, http和socket二选一,或者均不设置 + // client.setHttpProxy("proxy_host", proxy_port); // 设置http代理 + // client.setSocketProxy("proxy_host", proxy_port); // 设置socket代理 + + // 可选:设置log4j日志输出格式,若不设置,则使用默认配置 + // 也可以直接通过jvm启动参数设置此环境变量 + System.setProperty("aip.log4j.conf", "path/to/your/log4j.properties"); + + // 调用接口 + JSONObject res = client.basicGeneral(path, new HashMap()); + /*Map m=res.toMap(); + Set s=m.entrySet();*//* + + for (Object str : s) { + System.out.println(str); + } + //System.out.println(s);*/ + String str= res.toString(0); + /*for(int i=0;i='a'&&c<='z')||(c>='A'&&c<='Z')||c=='{'||c=='"'||c==':'||c=='}'||c==':'||c=='_'){ + continue; + } + else + s+=c; + if(c==']')break; + } + //System.out.println(s); + CovidTestRep CTR=new CovidTestRep(); + for(int i=0;i()); + String str= res.toString(0); + + int flag = 0; + int flag1 = 0; + int flag2 = 0; + HealthCode HC = new HealthCode(); + for (int i = 16; i < str.length(); i++) { + char c = str.charAt(i); + if (c == '[' && flag == 0) { + flag = 1; + } else if (flag == 1 && c == ']') { + break; + } else { + if (i == 27) { + String N = HC.getName(); + for (; str.charAt(i) != '\"'; i++) { + N = N + str.charAt(i); + + } + HC.setName(N); + } + + + if (str.charAt(i) == '-' && flag1 == 0) { + flag1 = 1; + String D = HC.getData(); + for (i = i - 4; str.charAt(i) != '\"'; i++) { + D = D + str.charAt(i); + } + HC.setData(D); + } + if (str.charAt(i) == '码' && flag2 == 0) { + flag2 = 1; + String S = HC.getStatus(); + S = S + str.charAt(i - 1); + HC.setStatus(S); + } + } + } + return HC; + } +} \ No newline at end of file diff --git a/src/OCR_baidu/src/META-INF/MANIFEST.MF b/src/OCR_baidu/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..a30bfa7 --- /dev/null +++ b/src/OCR_baidu/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: HealthCode + diff --git a/src/OCR_baidu/src/TripCode.java b/src/OCR_baidu/src/TripCode.java new file mode 100644 index 0000000..6cd45a4 --- /dev/null +++ b/src/OCR_baidu/src/TripCode.java @@ -0,0 +1,146 @@ +import com.baidu.aip.ocr.AipOcr; +import org.json.JSONObject; + +import java.util.HashMap; +public class TripCode { + private String Status; + private String Telephone; + private String Time; + private String District; + + public TripCode() { + Status = ""; + Telephone = ""; + Time = ""; + District = ""; + } + + public void setStatus(String status) { + Status = status; + } + + public void setTelephone(String telephone) { + Telephone = telephone; + } + + public void setTime(String time) { + Time = time; + } + + public void setDistrict(String district) { + District = district; + } + + public String getTelephone() { + return Telephone; + } + + public String getStatus() { + return Status; + } + + public String getDistrict() { + return District; + } + + public String getTime() { + return Time; + } + + public void Print() { + System.out.println("Status:" + this.Status); + System.out.println("Telephone:" + this.Telephone); + System.out.println("Time:" + this.Time); + System.out.println("District:" + this.District); + } + + public static void main(String[] args) { + String path = "C:\\Users\\16491\\Desktop\\1.jpg"; + System.out.println(Judge(path)); + } + + /*}; + class OCR2 { + //设置APPID/AK/SK*/ + public static String Judge(String path) { + TripCode T = new TripCode(); + T = ocr2(path); + String InfM = T.Status + "," + T.Telephone + "," + T.Time + "," + T.District; + return InfM; + } + + public static TripCode ocr2(String path) { + final String APP_ID = "28049220"; + final String API_KEY = "qyKlUy6xSapA89DTPomExteq"; + final String SECRET_KEY = "q5EYpXULVh5gC3firLU1nGaymwIwOMBd"; + + + // 初始化一个AipOcr + AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY); + + // 可选:设置网络连接参数 + client.setConnectionTimeoutInMillis(2000); + client.setSocketTimeoutInMillis(10000); + + // 可选:设置代理服务器地址, http和socket二选一,或者均不设置 + // client.setHttpProxy("proxy_host", proxy_port); // 设置http代理 + // client.setSocketProxy("proxy_host", proxy_port); // 设置socket代理 + + // 可选:设置log4j日志输出格式,若不设置,则使用默认配置 + // 也可以直接通过jvm启动参数设置此环境变量 + System.setProperty("aip.log4j.conf", "path/to/your/log4j.properties"); + + // 调用接口 + JSONObject res = client.basicGeneral(path, new HashMap()); + //System.out.println(res); + String str = res.toString(0); + //System.out.println(str); + String s = ""; + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '{' || c == '"' || c == ':' || c == '}' || c == ':' || c == '_') { + continue; + } else + s += c; + if (c == ']') break; + } + //System.out.println(s); + TripCode TC = new TripCode(); + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) == '的' && s.charAt(i + 1) == '动' && s.charAt(i + 2) == '态' && s.charAt(i + 3) == '行' && s.charAt(i + 4) == '程' && s.charAt(i + 5) == '卡') { + String tel = TC.getTelephone(); + for(;s.charAt(i)!=',';i--); + i++; + for (; s.charAt(i) != ','; i++) { + tel += s.charAt(i); + } + TC.setTelephone(tel); + } + if (s.charAt(i) == '请' && s.charAt(i + 1) == '收' && s.charAt(i + 2) == '下') { + String St = TC.getStatus(); + i = i + 3; + for (; s.charAt(i) != ','; i++) { + St += s.charAt(i); + } + TC.setStatus(St); + } + if (s.charAt(i) == '更' && s.charAt(i + 1) == '新' && s.charAt(i + 2) == '于') { + String Data = TC.getTime(); + i = i + 3; + for (; s.charAt(i) != ','; i++) { + Data += s.charAt(i); + } + TC.setTime(Data); + } + if (s.charAt(i) == '到' && s.charAt(i + 1) == '达' && s.charAt(i + 2) == '或' && s.charAt(i + 3) == '途' && s.charAt(i + 4) == '经') { + String Dis = TC.getDistrict(); + i = i + 5; + for (; s.charAt(i) != ']'; i++) { + Dis += s.charAt(i); + } + TC.setDistrict(Dis); + } + } + return TC; + } +} diff --git a/test.py b/test.py new file mode 100644 index 0000000..887a068 --- /dev/null +++ b/test.py @@ -0,0 +1,13 @@ +from openpyxl import load_workbook +from openpyxl.styles import * + +def style(file): + wb = load_workbook(file) + ws = wb.active + for row in ws.iter_rows(): + for cell in row: + if cell is not None: + cell.alignment = Alignment(horizontal='center',vertical='center') + wb.save(file) + +style('测试3.xlsx') \ No newline at end of file diff --git a/冯健铠 b/冯健铠 new file mode 100644 index 0000000..e69de29 diff --git a/新建文本文档 (2).txt b/新建文本文档 (2).txt new file mode 100644 index 0000000..14e992b --- /dev/null +++ b/新建文本文档 (2).txt @@ -0,0 +1 @@ +二点发发发的 \ No newline at end of file diff --git a/新建文本文档.txt b/新建文本文档.txt new file mode 100644 index 0000000..2e65efe --- /dev/null +++ b/新建文本文档.txt @@ -0,0 +1 @@ +a \ No newline at end of file