印章识别OCR API
小艾同学 ... 大约 1 分钟
# 印章识别OCR API
# 简介
用户需要先注册登录,然后才能正常使用。注意使用的时候需要带 token。
# 示例图片
# 接口/路由/入口
- 接口名称:印章识别OCR
- 接口地址:https://www.docpartner-serve.com/python/bpInterfaceSealtrocrModel
- 请求方式:POST
- 响应类型:JSON(同步)
- content-type:application/json
# 输入说明
{
"requestData": {
"queryDataDict": "asdfasf", // base64 图片base64 数据 不需要 data 开头
}
}
1
2
3
4
5
2
3
4
5
# 输出说明
{
"isSuccessful": True,
"errorMsg" : "",
"data" : {
"respData":{
"topStr":'印章顶部文字',
"cFontStr":'印章中间文字第一行',
"cFontStr1":'印章中间文字第二行,如果有的话,否则空',
"bottomStr":'印章底部文字'
"sealType": "印章形状:圆或椭圆,__iscircle__ __isellips__"
"isHasStar":"是否有五角星"
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# 程序示例
# js 示例
// 基于 axios
import axios from "axios"
let token = "TODO" // TODO
let bpInterfaceSealtrocrModel = "/bpInterfaceSealtrocrModel"
let requestJsonData = {
requestData: {
queryDataDict: "TODO", // base64 字符串
}
}
axios.post(
bpInterfaceSealtrocrModel,
requestJsonData,
{
baseURL: 'https://www.docpartner-serve.com/python/', // TODO
headers: {
"Authorization":`Bearer ${token}`,
"Content-Type":"application/json;charset=utf-8",
},
responseType: 'json'
}
)
.then(resp => {
if (resp.data.isSuccessful) {
console.log(resp.data.data)
} else {
console.log(`请求api失败!${resp.data.errorMsg}`);
}
})
.catch(err => {
console.log(err)
})
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
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
# python 示例
# 基于 requests - 已测试
import os
import base64
import requests
token = "" # TODO
bp = "bpInterfaceSealtrocrModel"
url = "https://www.docpartner-serve.com/python/{bp}".format(
bp=bp
) # 接口地址
imgPath = "test.png" # TODO
with open(imgPath, "rb") as f:
imgDataStr = base64.b64encode(f.read()) # --> b''
imgDataBase64 = imgDataStr.decode() # --> str 图片 base64 编码成字符串
jsondata = {
"requestData": {
"queryDataDict": imgDataBase64,
}
}
headers = {
'Authorization': "Bearer " + token
}
r = requests.post(url,headers=headers,data=None,json=jsondata)
assert type(r.json()) == dict
print(r.json())
# {'data': {'respData': {'bottomStr': ' 9 1 5 2 2 2 7 0 1 0 9 8 5 4 8 6 5 5 5 9 ', 'cFontStr': ' 人 事 专 用 章 ', 'cFontStr1': ' ', 'sealType': ' __isellips__', 'topStr': ' 贵 州 德 容 资 产 管 理 有 限 公 司 '}}, 'errorMsg': '', 'isSuccessful': True}
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
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